Seconds or milliseconds? Reading a Unix timestamp
Count the digits. For dates between 2001 and 2286, a timestamp in seconds has 10 digits, milliseconds 13, microseconds 16 and nanoseconds 19. 1700000000000 has 13 digits, so it is milliseconds: 22:13:20 UTC on 14 November 2023.
1700000000000 read as milliseconds since 1970-01-01 00:00 UTC is Tuesday, 2023-11-14 22:13:20 UTC.
- ISO 8601 (UTC)
2023-11-14T22:13:20Z- Your time zone
shown when JavaScript runs- RFC 2822 / email
Tue, 14 Nov 2023 22:13:20 +0000- HTTP date
Tue, 14 Nov 2023 22:13:20 GMT- Seconds
1700000000- Milliseconds
1700000000000- Day of week (UTC)
Tuesday- ISO week
2023-W46- Day of year
318- Fits in 32-bit signed time_t
yes
What to know
Unix tools and most APIs use seconds (date +%s, PostgreSQL's extract(epoch …), JWT exp claims). JavaScript's Date.now() and Java's System.currentTimeMillis() use milliseconds. Python's time.time() returns seconds as a float, and time.time_ns() nanoseconds. Go's time.Now().Unix() is seconds, UnixMilli() milliseconds.
Reading milliseconds as seconds gives a date tens of thousands of years in the future; reading seconds as milliseconds gives a date in January 1970. Either is a strong hint that the unit is wrong.
Gotchas
- The digit rule fails for dates close to 1970: 86400 is one day in seconds, but also 86.4 seconds in milliseconds. The converter on this page lets you pick the unit.
- JavaScript:
new Date(1700000000)is 20 January 1970. Multiply seconds by 1000 first.