What Unix time is
Unix time is the number of seconds elapsed since 1970-01-01T00:00:00Z — the "epoch." It is timezone-free, always monotonic (mostly), and takes a single integer to represent any moment for the next few thousand years.
Some systems use milliseconds instead of seconds. JavaScript's Date.now() returns milliseconds; most Unix system calls return seconds. Getting the unit wrong is the single most common bug.
Everything runs in your browser. The current-time counter reads your device clock; conversions use the built-in Date API.
Seconds vs. milliseconds — how to tell
Count the digits at 2025-06:
- Seconds: 10 digits (
1_749_x_xxx_xxx). - Milliseconds: 13 digits.
Anything between 10 and 12 digits is almost certainly seconds. Anything 13+ is almost certainly milliseconds.
Round-trip formulas
// JavaScript, ms → Date
const d = new Date(1749_000_000_000)
// JavaScript, seconds → Date
const d2 = new Date(1_749_000_000 * 1000)
// Date → Unix seconds
Math.floor(Date.now() / 1000)
// Date → Unix ms
Date.now()
ISO 8601 — the safest wire format
When you have to send a date across systems, use ISO 8601 in UTC ("Zulu") form:
2025-06-14T12:34:56Z
It is human-readable, sortable as a string, timezone-explicit, and every language's date parser understands it.
The 2038 problem
32-bit signed integers overflow on 19 Jan 2038, 03:14:07 UTC. Systems written before ~2010 that stored time as int32 will wrap around to 1901. Modern platforms use 64-bit integers — the sun will burn out first.
Check any legacy database columns that store Unix time as a 32-bit integer.
Common mistakes
- Mixing seconds and milliseconds. Always label your columns / variables.
- Assuming local time. Unix time is UTC. Always convert at the edges of your system.
- Using
new Date('2025-06-01'). That parses as UTC in some browsers, local in others. Usenew Date('2025-06-01T00:00:00Z'). - Storing dates as strings. Store timestamps as integers, format them at render time.
- Ignoring leap seconds. POSIX Unix time pretends leap seconds don't exist. Rarely matters, worth knowing.
FAQ
Why 1970? Unix was designed in 1969-1970. The epoch was set to the first second of the year Unix shipped.
Does Unix time include leap seconds? No. POSIX defines Unix time as days_since_epoch * 86400 + seconds_in_day — leap seconds are silently skipped.
What is the largest Unix time? 2^63 - 1 on modern 64-bit systems — about 292 billion years from now.