Current Time
now / System Time Zone
Julia provides the now() method to retrieve your current system's time as a DateTime. The TimeZones.jl package provides an additional now(::TimeZone) method providing the current time as a ZonedDateTime:
now(tz"Europe/Warsaw")To get the TimeZone currently specified on you system you can use localzone(). Combining this method with the new now method produces the current system time in the current system's time zone:
now(localzone())today
Similar to now the TimeZones package also provides a today(::TimeZone) method which allows you to determine the current date as a Date in the specified TimeZone.
julia> a, b = now(tz"Pacific/Midway"), now(tz"Pacific/Apia")ERROR: LoadError: ArgumentError: The time zone "Pacific/Midway" is of class `TimeZones.Class(:LEGACY)` which is currently not allowed by the mask: `TimeZones.Class(:FIXED) | TimeZones.Class(:STANDARD)` in expression starting at REPL[1]:1julia> a - bERROR: UndefVarError: `a` not definedjulia> today(tz"Pacific/Midway"), today(tz"Pacific/Apia")ERROR: LoadError: ArgumentError: The time zone "Pacific/Midway" is of class `TimeZones.Class(:LEGACY)` which is currently not allowed by the mask: `TimeZones.Class(:FIXED) | TimeZones.Class(:STANDARD)` in expression starting at REPL[3]:1
You should be careful not to use today() when working with ZonedDateTimes as you may end up using the wrong day. For example:
julia> midway, apia = tz"Pacific/Midway", tz"Pacific/Apia"ERROR: LoadError: ArgumentError: The time zone "Pacific/Midway" is of class `TimeZones.Class(:LEGACY)` which is currently not allowed by the mask: `TimeZones.Class(:FIXED) | TimeZones.Class(:STANDARD)` in expression starting at REPL[1]:1julia> ZonedDateTime(today() + Time(11), midway)ERROR: UndefVarError: `midway` not definedjulia> ZonedDateTime(today() + Time(11), apia) # Wrong date; with the current rules apia should be one day ahead of midwayERROR: UndefVarError: `apia` not definedjulia> ZonedDateTime(today(midway) + Time(11), midway)ERROR: UndefVarError: `midway` not definedjulia> ZonedDateTime(today(apia) + Time(11), apia)ERROR: UndefVarError: `apia` not defined
Alternatively, you can use the todayat function which takes care of this for you:
julia> todayat(Time(11), tz"Pacific/Midway")ERROR: LoadError: ArgumentError: The time zone "Pacific/Midway" is of class `TimeZones.Class(:LEGACY)` which is currently not allowed by the mask: `TimeZones.Class(:FIXED) | TimeZones.Class(:STANDARD)` in expression starting at REPL[1]:1julia> todayat(Time(11), tz"Pacific/Apia")2025-11-28T11:00:00+13:00