Unix Timestamp & Epoch Time Explained
Every Unix timestamp is UTC, always — that's not a convention, it's the entire reason the format is useful. Here's why storing local "wall-clock" time instead causes bugs that only appear twice a year, what leap seconds do to the count, and how to get "now" as epoch across five languages.
// why "UTC by definition" is the whole point
2:30 AM never happens that day. During "fall back," 1:00–1:59 AM occurs twice — a stored local timestamp of 1:30 AM doesn't say which occurrence it means. Neither problem can happen to a Unix timestamp, because it isn't wall-clock time — it's a single, unambiguous instant. A scheduled job or event stored as local time can silently fire twice, not at all, or at the wrong hour on transition days; the same job stored as epoch/UTC never has this failure mode.// getting "now" as epoch, by language
Date.now() — millisecondsDateTimeOffset.UtcNow.ToUnixTimeSeconds() / ToUnixTimeMilliseconds()time.time() — float seconds, sub-second precision includedEXTRACT(EPOCH FROM NOW()) — seconds, with a fractional partUNIX_TIMESTAMP() — secondsdate +%s — seconds// leap seconds: ignored by design, not by accident
Real UTC occasionally inserts a leap second to stay aligned with Earth's slightly irregular rotation. POSIX time explicitly does not count them — the standard defines every day as exactly 86,400 seconds, full stop. When a leap second is inserted in reality, Unix time either repeats a second or is adjusted by the OS ("smeared" across the surrounding hours) depending on the system — either way, the raw count quietly diverges from true elapsed seconds by design, not by bug. As of 2025, 27 leap seconds have accumulated since 1972; international standards bodies (BIPM) have agreed to stop inserting new ones by 2035, with a final vote expected in 2026, which will freeze this drift rather than reverse it.
// epoch vs. ISO 8601 — different tools for different jobs
ISO 8601's field order (year → month → day → hour...) means lexicographic string sorting matches chronological order — a rare and genuinely useful property, which is why log files and filenames often use it. Epoch numbers sort correctly too, but only when compared as actual numbers; naively comparing them as zero-padded strings of different lengths breaks the same way any numeric string comparison does. Pick epoch for compact storage and arithmetic (durations, comparisons), ISO 8601 for anything a human will read directly — logs, API responses meant for debugging, config files.
// try it yourself
Convert a Unix timestamp (seconds or milliseconds, auto-detected) to a readable date in both UTC and your local timezone, or go the other way, with the Unix Timestamp / Epoch Converter — including a live clock showing the current epoch value as it ticks.
A Unix timestamp has no timezone attached because it doesn't need one — it's a count of seconds from a single fixed instant, so
1735689600means the exact same moment everywhere on Earth. The timezone only re-enters the picture when you convert it to a human-readable string for display. This is precisely why storing timestamps as epoch (or any UTC value) and converting to local time only at the display layer is the correct default — the alternative, storing "local wall-clock time," runs straight into a problem epoch time was designed to avoid entirely.