Units: count the digits first
A timestamp doesn't say what it counts. The same moment is 10 digits in seconds and 19 in nanoseconds, and every extra group of three is just more precision. The converter reads the unit from the length: up to 11 digits seconds, 12-14 milliseconds, 15-17 microseconds, 18 and up nanoseconds.
Read in the wrong unit
The number is fine; the reading is not. Two everyday mistakes put the same moment half a century too early or tens of thousands of years too late.
- 1Right unitread as seconds
new Date(1700000000 * 1000)→ Tue, Nov 14, 2023, 22:13:20 UTCSeconds, read as seconds. - 2Wrong unitread as milliseconds
new Date(1700000000)→ Tue, Jan 20, 1970, 16:13:20 UTCJavaScript Date wants milliseconds. Hand it seconds and a 2023 moment lands in January 1970. - 3Wrong unitread as seconds
Date.now() saved as seconds→ Sun, Nov 08, 55840, 22:13:20 UTCDate.now() is milliseconds. Store it where seconds belong and the date runs off the calendar.