Ecto v1.1.0 Ecto.DateTime
An Ecto type that includes a date and a time.
Summary
Functions
Casts the given value to datetime
Same as cast/1
but raises on invalid datetimes
Compare two datetimes
Converts an Ecto.DateTime
into a {date, time}
tuple
Converts the given Ecto.Date
into Ecto.DateTime
with the time being
00:00:00
Converts the given Ecto.Date
and Ecto.Time
into Ecto.DateTime
Returns an Ecto.DateTime
from an Erlang datetime tuple
Converts a {date, time}
tuple into an Ecto.DateTime
Returns an Ecto.DateTime
in local time
Converts Ecto.DateTime
into an Ecto.Date
Returns an Erlang datetime tuple from an Ecto.DateTime
Converts Ecto.DateTime
to its ISO 8601 UTC representation if the
Ecto.DateTime
is UTC
Converts Ecto.DateTime
to its string representation
Converts Ecto.DateTime
into an Ecto.Time
The Ecto primitive type
Returns an Ecto.DateTime
in UTC
Functions
Casts the given value to datetime.
It supports:
- a binary in the “YYYY-MM-DD HH:MM:DD” format
(may be separated by T and/or followed by “Z”, as in
2014-04-17T14:00:00Z
) - a binary in the “YYYY-MM-DD HH:MM:DD.USEC” format
(may be separated by T and/or followed by “Z”, as in
2014-04-17T14:00:00.030Z
) - a map with
"year"
,"month"
,"day"
,"hour"
,"min"
keys with"sec"
and"usec"
as optional keys and values are integers or binaries - a map with
:year
,:month
,:day
,:hour
,:min
keys with:sec
and:usec
as optional keys and values are integers or binaries - a tuple with
{{year, month, day}, {hour, min, sec}}
as integers or binaries - a tuple with
{{year, month, day}, {hour, min, sec, usec}}
as integers or binaries - an
Ecto.DateTime
struct itself
Same as cast/1
but raises on invalid datetimes.
Compare two datetimes.
Receives two datetimes and compares the t1
against t2
and returns :lt
, :eq
or :gt
.
Converts an Ecto.DateTime
into a {date, time}
tuple.
Converts the given Ecto.Date
into Ecto.DateTime
with the time being
00:00:00.
Converts the given Ecto.Date
and Ecto.Time
into Ecto.DateTime
.
Returns an Ecto.DateTime
from an Erlang datetime tuple.
Converts a {date, time}
tuple into an Ecto.DateTime
.
Returns an Ecto.DateTime
in local time.
WARNING: Using the local time of the server will often lead to intermittent bugs.
This function only exists for legacy purposes. It is recommended to not
use this function. Please use the utc/1
function instead.
Converts Ecto.DateTime
into an Ecto.Date
.
Returns an Erlang datetime tuple from an Ecto.DateTime
.
Converts Ecto.DateTime
to its ISO 8601 UTC representation if the
Ecto.DateTime
is UTC.
WARNING: This will produce an incorrect result unless the datetime is UTC!
Make sure that the datetime is UTC. inserted_at
and updated_at
fields
populated by the Ecto timestamps
feature are UTC. But other Ecto.DateTime
fields are not always UTC.
Converts Ecto.DateTime
to its string representation.
Converts Ecto.DateTime
into an Ecto.Time
.
Returns an Ecto.DateTime
in UTC.
precision
can be :sec
or :usec
.