The Developer's Guide to Timezone Conversion and Management
Stop struggling with timezones. Learn best practices for handling UTC, local time, Daylight Saving Time (DST), and offsets in distributed systems.
Table of Contents
Quick Summary
America/New_York) right before rendering the UI for the user.The Golden Rule of Time
If you take away only one lesson from this guide, let it be this: Store as UTC, Display as Local.
Think of UTC as your application's absolute source of truth. When an event happens—a user clicks a button, a transaction goes through, a server crashes—it happens at a single absolute point in time. The database does not care if the user who clicked the button was in Tokyo or London.
UTC vs. GMT
While often used interchangeably by laypeople, UTC and GMT are different concepts in programming.
- UTC (Coordinated Universal Time): A time standard. It is not a time zone. It is the foundation by which all time zones are calculated.
- GMT (Greenwich Mean Time): A time zone. It happens to share the exact same current time as UTC, but it is a political zone used by countries like the UK, which can (and do) observe Daylight Saving Time (BST).
Understanding Offsets
An offset is the difference in hours and minutes from UTC. For example, standard time in New York is UTC-05:00, meaning it is 5 hours behind UTC.
Offsets are NOT Timezones
2026-05-21T14:00:00-05:00 in your database is better than storing local time without an offset, but it is still incomplete. Why? Because an offset doesn't tell you the location. Without the location, you cannot accurately predict what the local time will be 6 months in the future when Daylight Saving Time changes.The IANA Time Zone Database
To properly localize time, you must use an IANA identifier, like Europe/London or Asia/Kolkata.
The IANA Time Zone Database is a massive, constantly updated ledger of timezone rules. Because politicians frequently change when DST starts, stops, or if a timezone is abolished altogether, relying on fixed offsets is dangerous. The IANA database maps identifiers to their historical and future offsets.
Daylight Saving Time (DST)
DST is the practice of advancing clocks during warmer months so that darkness falls at a later clock time. It is a nightmare for programmers.
If you need to schedule a recurring meeting for "Every Monday at 9:00 AM in New York", you cannot save this as "Every Monday at 14:00 UTC". When New York switches from EDT (UTC-4) to EST (UTC-5), that 14:00 UTC meeting will suddenly occur at 8:00 AM or 10:00 AM local time. You must store the rule: 09:00 and the zone America/New_York.
Common Mistakes
Relying on the Server's Local Clock
- Assuming a Day is 24 Hours: When DST starts, a day has 23 hours. When DST ends, a day has 25 hours. Never calculate "tomorrow" by simply adding
86400seconds. Let a timezone-aware library handle calendar math. - Using Three-Letter Abbreviations: Acronyms like CST can mean Central Standard Time (US), China Standard Time, or Cuba Standard Time. Never use them for parsing; use IANA names.
Best Practices
- Store absolute timestamps (like "Account Created") as standard ISO 8601 UTC strings (e.g.
2026-05-21T10:00:00Z) or Unix Epoch seconds. - Store future, calendar-based events (like "Dentist Appointment at 9am") as a combination of a local time string and an IANA zone (e.g.
09:00andAmerica/Los_Angeles). - Send UTC down the wire (API responses), and convert it to the user's local timezone in the frontend client (Browser/App).
- Use native
Intl.DateTimeFormatin JavaScript to format dates for the user.
Cheatsheet / Code Examples
JavaScript (Vanilla / Native)
// 1. Get current time in UTC ISO format (for database)
const dbTime = new Date().toISOString(); // "2026-05-21T14:00:00.000Z"
// 2. Format a UTC date string to the User's local timezone
const dateString = "2026-05-21T14:00:00Z";
const localStr = new Intl.DateTimeFormat('en-US', {
dateStyle: 'full',
timeStyle: 'long',
}).format(new Date(dateString));
// 3. Format a UTC date to a SPECIFIC timezone
const tokyoTime = new Intl.DateTimeFormat('en-US', {
timeZone: 'Asia/Tokyo',
timeStyle: 'long'
}).format(new Date(dateString));Python (ZoneInfo)
from datetime import datetime, timezone
from zoneinfo import ZoneInfo
# 1. Current UTC time
now_utc = datetime.now(timezone.utc)
# 2. Convert UTC to a specific timezone
tokyo_tz = ZoneInfo("Asia/Tokyo")
now_tokyo = now_utc.astimezone(tokyo_tz)
print(now_tokyo.isoformat())Frequently Asked Questions
Why shouldn't I just save dates in the user's local timezone?
Saving local time in a database causes severe synchronization issues in distributed systems. You cannot easily sort, compare, or migrate data if different rows are stored in different offsets. Always save as UTC.
What is the IANA Time Zone Database?
The IANA database (tzdata) is a collaborative compilation of information about the world's timezones. It defines standard identifiers like America/New_York which accurately account for historical DST rules and political changes.
Try It Yourself
Need to quickly verify the current time in different IANA zones? Use our completely free, client-side World Timezones utility.