For Developers
How to get the current timestamp, convert it to a date, and convert a date back to a timestamp in Julia, using the standard library's Dates module.
using Dates
ts = round(Int, datetime2unix(now(UTC)))
using Dates
ts = 1750000000
dt = unix2datetime(ts) # returns UTC DateTime
using Dates
dt = DateTime(2025, 6, 15, 12, 0, 0)
ts = datetime2unix(dt)
Julia's built-in Dates.DateTime type has no timezone concept at all — it's always a naive, unzoned value, and now() without an argument returns local system time, not UTC, unlike most languages designed more recently. Full timezone awareness needs the separate TimeZones.jl package and its ZonedDateTime type; mixing plain DateTime values (assumed local) with values that were actually computed in UTC is a common source of quietly wrong results in scientific-computing code that wasn't written with this distinction in mind from the start.
Paste it into the Timestamp ⇄ Date Converter to check it instantly, in any timezone, without writing any code. Working across several languages on the same project? The full Epoch Time in Programming Languages guide has all of them side by side for quick comparison.
Related
Every language's snippets side by side, for quick comparison.
Convert any timestamp instantly, no code required.
A similar data/scientific-computing language, with its own origin-argument quirk.