There are two types of developers: those who fear timezones, and those who haven't worked with them yet. It starts innocently enough. You store a date in your database. A user in London creates an appointment for 9:00 AM. A user in New York sees it as… 9:00 AM? Wait, that's wrong.

Time isn't just a number line; it's a political and geographical construct wrapped in messy code.

1. The "Add 24 Hours" Trap

New developers often think: "To get tomorrow's date, I'll just take today's timestamp and add 86,400 seconds (24 hours * 60 minutes * 60 seconds)."

This works most days. Until it doesn't.

Scenario: Daylight Saving Time (DST) begins. The clocks spring forward. That Sunday only has 23 hours. If you add 24 hours to midnight, you land at 1:00 AM on Monday, effectively skipping a day in your logic.

The Fix: Never do math on timestamps manually. Use a library like Luxon, Moment.js (legacy), or the native `Intl` API that understands calendar days vs. duration hours.

2. Server Time vs. User Time

If your server is in Virginia (AWS us-east-1) and your user is in Tokyo, `new Date()` means two very different things.

The Golden Rule: Always, always, always store time in UTC.

UTC (Coordinated Universal Time) is the constant. It has no Daylight Saving Time. It never changes. Convert input to UTC immediately upon receiving it. Store it as UTC. Only convert it back to the user's local time at the very last second—in the UI layer.

3. ISO 8601 is Your Best Friend

Stop storing dates as strings like "01/02/2026". Is that January 2nd or February 1st? Americans and Europeans will fight to the death over this.

ISO 8601 solves this ambiguity: `YYYY-MM-DDTHH:mm:ss.sssZ`.

  • T separates date and time.
  • Z at the end indicates UTC ("Zulu" time).
  • Sorting works alphabetically. `2026-02-01` comes after `2026-01-01`.

4. Leap Seconds

Did you know the Earth's rotation is slowing down? Occasionally, scientists decide to add a whole extra second (a leap second) to keep our clocks in sync with the sun.

Unix timestamps don't account for this. They pretend every day is exactly 86,400 seconds. When a leap second happens, systems can crash, hang, or duplicate jobs if not patched correctly. Most modern OS kernels handle this by "smearing" the second over a longer period, but it's a reminder: Time is physical, not just digital.

Conclusion

Time is hard. Don't reinvent the wheel. Use standard libraries, store in UTC, and test your code around DST boundaries.

Need to debug a timestamp? Use our Timestamp Converter to see exactly what that number means in every timezone.