Why Unix timestamp bugs show dates in 1970 and how to fix seconds versus milliseconds
A developer found that a billing page listed every subscription as expiring on 1970-01-21, which was traced to a millisecond timestamp being passed to code that expected seconds. The article explains converting timestamps in Python and Node.js, and how the resulting ValueError reveals the unit mismatch so it can be fixed by dividing by 1000. It also warns that naive datetimes are read as local time, causing eight-hour offsets between machines unless the timezone is set explicitly. Additional pitfalls include the 2038 overflow of 32-bit signed integers and differing date command syntax between GNU and BSD systems. The author recommends naming timestamp fields with their unit to avoid such errors.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.


Discussion (0)
Log in to join the discussion and vote.
Log in