Constructing dates and times
In order to construct new date/time objects representing the current date or time, Julia provides two helper functions, now
 and today
. Let's look at some examples in the read-eval-print loop (REPL):
julia> using Dates julia> d = today() 2018-11-08 julia> typeof(d) Date julia> dt = now() 2018-11-08T16:33:34.868 julia> dt |> typeof DateTime julia> t = Dates.Time(now()) 16:34:13.065 julia> typeof(t) Time
The now
function can also accept an additional argument to return the UTC time (without local adjustments for daylight savings):
julia> now(UTC)
2018-11-08T15:35:08.776
Internally, all the types wrap an Int64
value that can be accessed through the instant
field:
julia> dt.instant Dates.UTInstant{Millisecond}(63677378014868 milliseconds) julia> t.instant 75147529000000 nanoseconds julia> d.instant Dates.UTInstant{Day}(737006 days)
The instant
property of the objects reflects the precision level of each type...