Unix timestamps: seconds, milliseconds and the 2038 problem

A Unix timestamp is a count of seconds since 1970 with no timezone attached. Most bugs come from the three things that sentence leaves out — units, signedness and leap seconds.

The definition, and what it omits

Unix time is the number of seconds elapsed since 1970-01-01T00:00:00Z. It carries no timezone — it is an instant, not a wall-clock reading. Any timezone you see attached to a timestamp was applied at formatting time, by whatever displayed it.

That is why the Timestamp tool shows the same number four ways at once — ISO 8601, UTC, your local time and a relative phrase. Nothing is converted between formats; one instant is simply being described four ways.

Seconds or milliseconds: count the digits

The tool's input is seconds, so a pasted 13-digit value produces an absurd far-future date rather than a subtle error. That is deliberate: a timestamp bug that shows up as the year 58000 gets fixed, while one that shows up as a few hours off ships to production.

Negative timestamps are legal

Times before 1970 are simply negative. -86400 is 1969-12-31. Plenty of code paths assume a timestamp is unsigned and mangle historical dates — dates of birth being the classic casualty. If a system stores birthdays as Unix time, it needs to handle negatives.

The 2038 problem is real, and it is not only about clocks

A signed 32-bit integer runs out at 2147483647, which is 2038-01-19T03:14:07Z. One second later it wraps to 1901. Anything still storing time in a signed 32-bit field breaks then — and it breaks early for anything computing future dates: a 20-year mortgage schedule or a certificate expiry crosses the boundary today.

64-bit time is the fix and is already the norm on modern platforms; the risk lives in database columns, binary formats and embedded devices, not usually in your language's date type.

Leap seconds, and why your timestamp ignores them

POSIX time pretends every day has exactly 86,400 seconds. Real UTC occasionally inserts a leap second, so during one the Unix clock either repeats a value or is smeared slowly across the day, depending on the platform. The practical consequence: a difference of Unix timestamps is not exactly the elapsed physical time, and it can be off by a couple of dozen seconds across decades.

For anything where the answer matters — durations, SLAs, timers — measure with a monotonic clock rather than subtracting wall-clock timestamps. For human-scale differences, the Date Difference and Duration tools are the right shape.

Storing and transmitting: pick one and be boring

Tools used in this guide