All guides

What Is a Unix Timestamp?

A single number for a moment

A Unix timestamp is the number of seconds that have passed since midnight at the start of 1 January 1970, UTC. That is all it is: one long count, growing by one every second, with no months, no time zones and no daylight saving to argue about. Computers love it because comparing two moments becomes subtracting two numbers, and sorting events becomes sorting integers. The chosen start point is called the epoch, and it was picked when the Unix system was young and 1970 was simply a convenient recent round date. You can meet the current timestamp any time by asking a computer, and converting it is a good party trick for developers: the ten digit count for this moment corresponds to a perfectly ordinary date and time in UTC, which is the only zone timestamps recognise.

Seconds, milliseconds and friends

The classic timestamp counts seconds, but many systems store milliseconds instead, which makes the number a thousand times bigger and confuses everyone at least once. The quick test is size: a current timestamp in seconds is about 1.8 billion, ten digits, while in milliseconds it is thirteen digits. Databases, logs and APIs all have their own habits, so when a converted date lands in 1970 or in the year 56000, the unit is wrong, not the data. Good converters detect the size and tell you which they assumed. Negative timestamps exist too, counting backwards from the epoch into 1969 and beyond, and well behaved converters handle them, although older software often refuses dates before 1970 for no better reason than that its author never expected to need them.

The 2038 problem

Older systems stored the count in a signed 32 bit integer, whose largest value runs out on 19 January 2038. After that moment, such a counter would wrap around to a date in 1901. Modern systems mostly use 64 bit counts, which will not run out for hundreds of billions of years, but old embedded devices, file formats and protocols still carry the 32 bit limit. It is a useful reminder that a timestamp is not a date at all, just a count with an agreement about where counting started. The deeper point is that the timestamp separates the moment from its description. The moment is universal; the description, the date, the zone, the language of the month names, is local. Systems that remember that distinction rarely produce the classic bug of a meeting stored at the wrong hour.

Try it yourself

The free calculator that goes with this guide:

Convert a Unix timestamp