DateTime.from_gregorian_seconds
You're seeing just the function
from_gregorian_seconds
, go back to DateTime module for more information.
Link to this function
from_gregorian_seconds(seconds, arg \\ {0, 0}, calendar \\ Calendar.ISO)
View Source (since 1.11.0)Specs
from_gregorian_seconds(integer(), Calendar.microsecond(), Calendar.calendar()) :: t()
Converts a number of gregorian seconds to a DateTime
struct.
The returned DateTime
will have UTC
timezone, if you want other timezone, please use
DateTime.shift_zone/3
.
Examples
iex> DateTime.from_gregorian_seconds(1)
~U[0000-01-01 00:00:01Z]
iex> DateTime.from_gregorian_seconds(63_755_511_991, {5000, 3})
~U[2020-05-01 00:26:31.005Z]
iex> DateTime.from_gregorian_seconds(-1)
~U[-0001-12-31 23:59:59Z]