What a Unix timestamp counts
Unix time is the number of seconds since 00:00:00 UTC on 1 January 1970, called the epoch, ignoring leap seconds. It has no time zone: one number names one instant everywhere, and zones only appear when you display it. JavaScript's Date counts in milliseconds, which is why you meet both 10-digit and 13-digit values.
Worked example
Entering 1700000000 gives:
| Field | Value |
|---|---|
| UTC | Tue, 14 Nov 2023 22:13:20 GMT |
| ISO 8601 | 2023-11-14T22:13:20.000Z |
| Local | The same instant in your browser's time zone and locale format |
Entering the 13-digit 1700000000000 gives the identical result. In the other direction, a date picked as 29 Feb 2024 12:00 is read as local time. If your computer is set to UTC, it converts to 1709208000 seconds or 1709208000000 milliseconds, and in any other zone you get a different number.
How seconds and milliseconds are told apart
There is no switch for this. The rule uses the digits before any decimal point: ten digits or fewer is treated as seconds, and anything longer is taken as milliseconds. The result is labelled "Read as seconds" or "Read as milliseconds" so you can check. That works for any date between September 2001 and November 2286. The rule has a few side effects.
- A decimal like
1700000000.5is read as seconds with half a second added, because only the digits before the point are counted. The ISO result shows.500Z. - An 11-digit number is treated as milliseconds, so it lands between 1970 and 1973 rather than in the far future.
- A negative timestamp counts back from the epoch:
-1is 23:59:59 UTC on 31 December 1969. - Text that is not a number, such as
abcor12:30, shows an error message, as does a value too large for JavaScript dates.
Handy reference values
| Seconds | Moment (UTC) |
|---|---|
| 0 | 1970-01-01 00:00:00 |
| 1000000000 | 2001-09-09 01:46:40 |
| 2147483647 | 2038-01-19 03:14:07, the limit of a signed 32-bit integer |
Systems that store seconds in 32 bits overflow one second later, the so-called Year 2038 problem, while 64-bit values last for billions of years. "Use now" fills in the current time in seconds. For the gap between two dates, use date difference, and to compare clock times across cities, the time zone converter.