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(1000000000 * 1000)→ Sun, Sep 09, 2001, 01:46:40 UTCSeconds, read as seconds. - 2Wrong unitread as milliseconds
new Date(1000000000)→ Mon, Jan 12, 1970, 13:46:40 UTCJavaScript Date wants milliseconds. Hand it seconds and a 2001 moment lands in January 1970. - 3Wrong unitread as seconds
Date.now() saved as seconds→ Fri, Sep 27, 33658, 01:46:40 UTCDate.now() is milliseconds. Store it where seconds belong and the date runs off the calendar.