Unix to Excel date conversion: three hidden pitfalls every developer should know
Converting between Unix timestamps and Excel serial dates involves three common failure points: the epoch reference, the unit of time, and a phantom date bug dating back to 1900. Excel's date system mistakenly includes 29 February 1900 — a day that never existed — inherited from a Lotus 1-2-3 bug that Microsoft deliberately preserved to maintain backward compatibility. The standard conversion formula divides a Unix timestamp by 86,400 and adds 25,569, the Excel serial number for 1 January 1970, but developers must also account for time zone offsets since Excel stores no timezone data. Digit count matters too, as 10-digit values are seconds, 13-digit are milliseconds, and 19-digit nanosecond timestamps can cause precision loss in JavaScript due to floating-point limits. Additional edge cases include the legacy 1904 date system used in older Mac Excel files, which shifts all dates by 1,462 days when opened in standard Excel.
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