DateTime
Many functions in this module require a time zone database. By default, it uses the default time zone database returned by Calendar.get_time_zone_database/0, which defaults to Calendar.UTCOnlyTimeZoneDatabase which only handles "Etc/UTC" datetimes and returns {:error, :utc_only_time_zone_database} for any other time zone.
need lib to handle timezones, use timex package
dt = DateTime.utc_now()
dt = ~U[2020-05-29 02:15:00Z] #Only UTC Timezone
# Change to first of month
%{dt | day: 1, hour: 0, minute: 0, second: 0, microsecond: {0, 0}}
dt |> DateTime.add(60, :second) #Expected :second, :millisecond, :microsecond, :nanosecondNative DateTime
No timezone data so because of daylight savings could occur twice or never
naive = ~N[2000-01-01 23:00:07]
naive.year #2000
naive.second #7
dt.year #2020
NaiveDateTime.add(~N[2014-10-02 00:29:10.021], 21, :second) UNIX
Comparison
Normally < and > don't work well
Last updated