How to Avoid Seconds vs. Milliseconds Bugs
Mixing 10-digit Unix seconds (common in Python, Go, PostgreSQL, and JWT exp/iat claims) with 13-digit JavaScript or Java milliseconds is one of the most frequent incident-debugging traps:
- 10-digit seconds:
1795370400→2026-11-22T18:00:00Z(passing this directly tonew Date(1795370400)in JS mistakenly produces January 1970). - 13-digit milliseconds:
1795370400000→2026-11-22T18:00:00Z(passing this to a seconds-expecting API jumps into the year 58,000+). - Verified check:
1795368000is2026-11-22T17:20:00Z, exactly 40 minutes before1795370400. - Negative & fractional epochs:
-86400resolves to1969-12-31T00:00:00Z, and negative decimals like-1.5floor to-2seconds.
Storage & Logging Best Practices
- Store timestamps as UTC Unix integers or ISO-8601 strings with explicit
Zor numeric offsets (2026-11-22T18:00:00Z). - Convert to canonical IANA zones (such as
Asia/KolkataorAmerica/New_York) only at display time so daylight saving transitions remain accurate. - Use the Unit selector whenever inspecting intentionally early 1970s millisecond timestamps.
Limits
JavaScript Date values cover roughly ±8.64 × 1015 milliseconds around 1970. ISO date inputs without a timezone offset are explicitly interpreted as UTC and labeled on screen.