Data Formats 2026-04-16

Fix Timestamp Conversion & Timezone Errors

Debug Unix timestamp issues: milliseconds vs seconds confusion, timezone mismatches, daylight saving time errors, and date parsing failures.

timestamp wrong timezone unix timestamp not working date parsing error epoch time conversion error

Timestamp bugs are among the sneakiest in software: they work fine during testing but break in production across timezones. This guide covers the most common timestamp and timezone issues.

Common errors covered

  1. 1 Unix timestamp in seconds vs milliseconds
  2. 2 Timezone mismatch between server and client
  3. 3 Daylight Saving Time (DST) causes off-by-one-hour
1

Unix timestamp in seconds vs milliseconds

Error message
Date shows as January 1970 instead of current date Date shows as year 53000+ (far future)
Root cause

Unix timestamps come in two flavors: seconds since epoch (10 digits) and milliseconds (13 digits). Using the wrong unit produces wildly wrong dates.

Step-by-step fix

  1. 1 Check digit count: 10 digits = seconds, 13 digits = milliseconds.
  2. 2 Use our Timestamp Converter to test both formats.
  3. 3 In JavaScript, Date.now() returns milliseconds; divide by 1000 for seconds.
  4. 4 In Python, time.time() returns seconds; multiply by 1000 for milliseconds.
Wrong
// JavaScript expects milliseconds, but got seconds
new Date(1713264000)
// Result: Mon Jan 20 1970 (wrong!)
Correct
// Multiply seconds by 1000 for JavaScript
new Date(1713264000 * 1000)
// Result: Tue Apr 16 2024 (correct!)

2

Timezone mismatch between server and client

Error message
Event shows at wrong time for users in different timezones Scheduled task runs hours early/late
Root cause

Storing or transmitting timestamps without timezone information leads to ambiguity. A timestamp of 2024-04-16 10:00:00 could mean UTC, EST, PST, or any other timezone.

Step-by-step fix

  1. 1 Convert the timestamp in our Timestamp Converter and check the timezone display.
  2. 2 Store all timestamps in UTC on the backend.
  3. 3 Include timezone in ISO 8601 format: 2024-04-16T10:00:00Z (Z = UTC).
  4. 4 Convert to local timezone only on the client side for display.
Wrong
// Ambiguous: which timezone?
const event = '2024-04-16 10:00:00';
new Date(event);  // Interpreted differently per browser!
Correct
// Explicit UTC timestamp
const event = '2024-04-16T10:00:00Z';
new Date(event);  // Always UTC, convert for display

3

Daylight Saving Time (DST) causes off-by-one-hour

Error message
Daily job runs at wrong time twice a year Timestamps shift by 1 hour on specific dates
Root cause

DST transitions create hours that do not exist (spring forward) or repeat (fall back). Naive timezone handling breaks during these transitions.

Step-by-step fix

  1. 1 Always store and compute times in UTC - convert to local only for display.
  2. 2 Use timezone-aware libraries (Luxon, date-fns-tz, pytz/zoneinfo).
  3. 3 Test with timestamps near DST transitions.
  4. 4 Use our Timestamp Converter to verify conversions around DST boundaries.
Wrong
# Naive datetime loses DST info
from datetime import datetime
dt = datetime(2024, 3, 10, 2, 30)  # This time may not exist!
Correct
# Timezone-aware datetime handles DST
from datetime import datetime
from zoneinfo import ZoneInfo
dt = datetime(2024, 3, 10, 2, 30, tzinfo=ZoneInfo('US/Eastern'))

Prevention Tips

  • Store all timestamps as UTC Unix timestamps or ISO 8601 with timezone.
  • Use Date.now() (JS) or time.time() (Python) for current timestamps.
  • Test your application with different system timezones before deployment.
  • Use our Timestamp Converter to validate conversions during development.

Frequently Asked Questions

What is Unix epoch time?

Unix epoch is January 1, 1970, 00:00:00 UTC. A Unix timestamp is the number of seconds (or milliseconds) since that moment. It is timezone-independent, making it ideal for storing and comparing times.

Why does Date.parse give different results in different browsers?

Date string parsing is one of the most inconsistent parts of JavaScript. Always use ISO 8601 format (2024-04-16T10:00:00Z) for reliable cross-browser parsing.

Should I use seconds or milliseconds for timestamps?

Most backend systems (Python, databases, Unix) use seconds. JavaScript uses milliseconds. APIs vary. Document which unit your system uses and convert at boundaries.

Related Error Guides

Related Tools

Still stuck? Try our free tools

All tools run in your browser, no signup required.