What is a Unix timestamp, and how do you convert one to a date?
A Unix timestamp is a single number that names a moment in time: the number of seconds that have passed since midnight at the start of 1 January 1970, in UTC. That starting point is called the Unix epoch. Computers like timestamps because they are easy to store, compare and sort.
Some timestamps and the dates they mean
| Timestamp | Date and time (UTC) |
|---|---|
| 0 | 1970-01-01 12:00:00 AM |
| 1,000,000,000 | 2001-09-09 1:46:40 AM |
| 1,700,000,000 | 2023-11-14 10:13:20 PM |
| 2,147,483,647 | 2038-01-19 3:14:07 AM |
Seconds or milliseconds?
Many programming languages and APIs count in milliseconds instead of seconds. A timestamp for a date today has 10 digits in seconds and 13 digits in milliseconds, so 1700000000 and 1700000000000 are the same moment. If a conversion gives you a date in the year 50,000, you probably have milliseconds where seconds were expected.
Time zones
A timestamp does not belong to any time zone. It is the same instant everywhere. A time zone only comes in when you turn the number into a date to read: 1700000000 is 10:13:20 PM in UTC, and the clock time in New York or Tokyo on the same instant is different.
When you compare or store moments, use the timestamp. When you show one to a person, convert it to their zone.
Dates before 1970 and the year 2038
Negative timestamps count backwards from the epoch, so -86400 is one day before it. Systems that store the timestamp in a signed 32-bit integer can only count up to 2,147,483,647, which is the last row of the table above. Newer systems use 64 bits and are not affected.
Unix Timestamp Converter: Turn a timestamp into a date in any time zone, or a date into a timestamp, in seconds or milliseconds.