Unix timestamp converter
Timestamps to dates and back. Unix time is not quite the number of seconds since 1970, and the difference is twenty-seven seconds of deliberate design. Nothing you type here leaves your browser — it is worked out on your own device, so there is nothing to send and nothing to log.
Unix time is not the number of seconds since 1970
It is very nearly that, and the difference matters. Unix time is defined as days since 1970 multiplied by 86,400, plus the seconds so far today — which is not the same as counting seconds, because 27 leap seconds have been inserted since 1972 and Unix time contains none of them.
So the counter is 27 seconds behind real elapsed time, and on a leap second the same timestamp covers two different instants. That is deliberate: it keeps the arithmetic simple — any timestamp divided by 86,400 is the day number, always — and pays for it by being wrong about duration. Most systems smear the extra second over a day rather than repeat it, which is a third answer again.
The last leap second was inserted at the end of 31 December 2016, and in November 2022 the General Conference on Weights and Measures resolved to stop inserting them by 2035.
The 2038 problem is real and dated
A signed 32-bit seconds counter runs out at
03:14:07 UTC on 19 January 2038, and the next second
is December 1901. That is not a theoretical concern: 32-bit
time_t is still in embedded systems, in file formats,
and in databases nobody is going to open again before then. Treat the
counter as unsigned and you get to 7 February 2106
instead, which is a different problem rather than a solution.
A timestamp is an instant, not a time
A timestamp says when, not what the clock said. Turning it into “3 pm on Tuesday” requires a time zone, and the timestamp does not carry one. Storing a meeting as a timestamp loses the answer to “what time did they mean?” the moment the clocks change — see the time zone converter.
Seconds, milliseconds, and the ones in between
Unix time is in seconds. JavaScript's
Date.now() is in milliseconds, Java and
most of the web are too, and a value pasted from one into the other is
wrong by a factor of a thousand — which shows up as a date in
1970 or in the year 55,000, both obvious. Microseconds and
nanoseconds also exist in the wild. This page guesses by magnitude and
says which it guessed.
What it will not do
- It will not account for leap seconds. Nothing using Unix time does; that is what Unix time is.
- It will not show you a local time unless you ask, because “local” is a property of the reader rather than of the timestamp.
- It will not go past 13 September 275760, which is where JavaScript's date type stops. Past that it says so rather than giving you a wrong answer.