timex_ecto v3.4.0 Timex.Ecto.Timestamps

Provides a simple way to use Timex with Ecto timestamps.

Example

defmodule User do
  use Ecto.Schema
  use Timex.Ecto.Timestamps

  schema "user" do
    field :name, :string
    timestamps()
  end

By default this will generate a timestamp with seconds precision. If you would like to generate a timestamp with more precision you can pass the option usec: true to the macro.

use Timex.Ecto.Timestamps, usec: true

For potentially easier use with Phoenix, add the following in web/web.ex:

def model do
  quote do
    use Ecto.Schema
    use Timex.Ecto.Timestamps
  end
end

This will bring Timex timestamps into scope in all your models