Time Zone HQ
12h
24h
-- -- ------:--:--
Deep Dives

How Computers Handle Time Zones

Your computer's system clock keeps time in UTC, and the operating system handles the conversion to local time at the moment something is displayed to you. This separation — store in UTC, display locally — is the architecture that makes global software work correctly. Understanding it helps diagnose subtle bugs and design better systems.

The System Clock

Modern computers (and phones) keep time via two mechanisms: a hardware real-time clock (RTC) chip that maintains time when the device is off, and periodic synchronization via NTP (Network Time Protocol) against authoritative servers that trace their accuracy back to atomic clocks. The hardware clock typically stores UTC, though some older BIOS systems stored local time — this was a common source of bugs in dual-boot Windows/Linux setups.

The TZ Environment Variable

On Unix-like systems, the active time zone is controlled by the TZ environment variable or the /etc/localtime file (which points to a zoneinfo binary). When a program calls localtime() or similar functions, the C library reads the current TZ setting and the corresponding zoneinfo file to determine the correct UTC offset for the current moment.

On Windows, time zone information is stored in the registry under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation. Windows uses its own time zone database, which mirrors the IANA database but with different identifiers ('Eastern Standard Time' rather than 'America/New_York'). Cross-platform applications often need to map between these two identifier sets.

Server vs. Browser Time

Web applications regularly deal with two different time zones: the server's zone and the user's browser zone. A server in UTC processes a request at 14:30 UTC. The same moment is 9:30 AM for a user in New York and 10:30 PM for a user in Tokyo. If your application stores timestamps in UTC and converts to local time in the browser using the browser's local timezone settings, you get correct results everywhere without any server-side knowledge of the user's location.

The browser exposes the local timezone via Intl.DateTimeFormat().resolvedOptions().timeZone (returns an IANA zone name) and the Date object's getTimezoneOffset() (returns the current UTC offset in minutes, negated). The Temporal API provides more ergonomic access to these values.

← Back to all articles
Help us make this better!