What is a Unix timestamp?
A Unix timestamp (epoch time) is the number of seconds since 00:00:00 UTC on 1 January 1970, not counting leap seconds. It is the same everywhere in the world at a given moment, which is why systems store time this way and convert to a local time zone only for display.
Because it is just a number, a timestamp is easy to sort, compare and subtract: the gap between two timestamps in seconds is the elapsed time, with no time zones or daylight saving to worry about. Every Unix day is treated as exactly 86,400 seconds, so a leap second is not counted as an extra second.
Seconds, milliseconds or more?
| Digits (today) | Unit | Used by |
|---|---|---|
| 10 | Seconds | Unix, PHP time(), Python time.time() (as a float), JWT |
| 13 | Milliseconds | JavaScript Date.now(), Java System.currentTimeMillis() |
| 16 | Microseconds | Python time.time_ns() // 1000, some databases and logging systems |
| 19 | Nanoseconds | Go UnixNano(), InfluxDB |
With Detect automatically, the converter reads values from 100 billion upward as milliseconds, from 100 trillion as microseconds and from 100 quadrillion as nanoseconds; anything smaller is seconds. Negative values and fractional seconds such as 1700000000.5 are accepted.
Worked example
Enter 1700000000. It is read as seconds and shows:
- UTC:
Tue, 14 Nov 2023, 22:13:20 UTC - ISO 8601:
2023-11-14T22:13:20.000Z - In New York:
Tue, 14 Nov 2023, 17:13:20 GMT-5
Now enter 1700000000000. The extra three digits make it milliseconds, and it resolves to exactly the same moment. Going the other way, 1 January 2025 00:00:00 with UTC selected gives 1735689600 seconds and 1735689600000 milliseconds.
UTC versus local time
A timestamp has no time zone; it marks one instant. Time zones only appear when you turn it into a calendar date. Store and transmit timestamps or UTC, and convert to the viewer's zone at the last step. When you enter a date to convert, The date is in matters: 09:00 in London and 09:00 UTC are the same instant in winter but an hour apart in summer.
ISO 8601 dates
ISO 8601 writes a date and time from largest to smallest unit, so strings sort correctly as text: 2023-11-14T22:13:20Z. The trailing Z means UTC; an offset such as 2023-11-14T17:13:20-05:00 describes the same moment in New York. Prefer one of these forms in APIs and logs over a local format like 14/11/2023, which is read differently in the US and Europe.
Get the current timestamp in code
JavaScript Math.floor(Date.now() / 1000) Python int(time.time()) Bash date +%s PHP time() Go time.Now().Unix() SQL (PG) extract(epoch from now())
The year 2038 problem
Systems that store timestamps as signed 32-bit integers overflow at 03:14:07 UTC on 19 January 2038 (2147483647). Modern systems use 64-bit values.
One second later, a signed 32-bit counter wraps to −2147483648, which is 20:45:52 UTC on 13 December 1901. Embedded devices, old file formats and database columns declared as 32-bit integers are the usual places this still lurks. An unsigned 32-bit value lasts until 7 February 2106; a signed 64-bit value lasts for billions of years.
Common mistakes
- Seconds passed as milliseconds. In JavaScript,
new Date(1700000000)treats the number as milliseconds and gives 20 January 1970. Multiply seconds by 1,000 first. - Milliseconds stored as seconds. The reverse gives a date tens of thousands of years in the future.
- Parsing a date without a zone. A string like
2023-11-14 22:13is read in the local zone by many libraries, so the same code gives different timestamps on different servers. - Assuming a day is 24 hours locally. On daylight saving changes a local day can be 23 or 25 hours long, even though Unix time counts every day as 86,400 seconds.
Edge cases
Very old millisecond timestamps can fool automatic detection: anything before 3 March 1973 has 11 digits or fewer in milliseconds and is read as seconds. Choose Milliseconds in Unit when you know the source. Timestamps beyond about the year 275,760 are outside the range JavaScript dates can show and produce no result.