Dates and Time Zones in Web i18n Engineering

Dates and Time Zones in Web i18n Engineering

A large class of date bugs stores one kind of time as another. Instants, wall-clock events, and plain dates, with store-UTC's three exceptions and an honest Temporal status.

A large class of timezone handling bugs in JavaScript comes from storing one kind of time as another. This article separates instants, wall-clock times, and plain dates; covers store-UTC-display-local and its three legitimate exceptions; treats zones and DST as data rather than arithmetic; resolves the server-client hydration mismatch; and gives Temporal's status honestly, with principles that hold whichever API a team builds on.

Two kinds of time

Everything in this article follows from one distinction.

An instant is a point on the global timeline. A payment was captured, a comment was posted, a log line was written. It happened at the same moment everywhere, and only its display differs by viewer.

A wall-clock time is what a clock reads in a particular place. A store opens at 9:00, a webinar starts at 15:00 in Lisbon, a delivery window runs from 8:00 to 12:00. It is meaningful only together with the place whose clocks it describes.

A large class of date bugs is one kind stored as the other. Store a store's opening hour as an instant and, in a zone that observes DST, it shifts by an hour twice a year. Store a payment timestamp as local wall-clock text and it becomes ambiguous the moment two regions read it.

There is a third citizen: the plain calendar date, with no time and no zone. A birthday, a public holiday, an all-day event, a contract's effective date. Force it through a timestamp and it acquires a time of midnight in some zone, and in any zone west of that one it displays as the previous day. The all-day event that shows up on the wrong day for part of the audience is this bug, and it is a recurring date defect on multi-region sites.

This sits in the i18n topic because the moment a site has users in a second region, every displayed time becomes a localization decision: which zone, which calendar, which format. Display mechanics, meaning the formatter's options, are the Intl article's territory. This article owns what is stored, what is transmitted, and which zone applies.

Store UTC, display local — and the exceptions

The default rule for instants is well known and correct: store UTC, display local. Persist the instant as an ISO 8601 string with Z or an explicit offset, or as epoch milliseconds, and convert to the viewer's zone only when rendering. One canonical timeline, no ambiguity at rest.

The rule's weakness is that teams apply it to things that are not instants. Three exceptions are legitimate, and each one is a different type, not a style preference.

Exception one: future wall-clock events. A conference in Berlin on March 14, 2027, at 9:00 is a promise about Berlin's clocks on that day. If you convert it to UTC today, you bake in today's offset rules for Berlin. Governments change those rules, sometimes with very little notice. If they do before the event, the stored UTC instant now corresponds to 8:00 or 10:00 local time, and every attendee's calendar is wrong. The correct storage is the wall time plus the IANA zone identifier, resolved to an instant at display time with whatever zone data is current then.

Exception two: recurring schedules. "Every Monday at 9:00 in Berlin" is a rule plus a zone. Expanding it into a list of UTC instants at creation time fixes every occurrence to the offset in effect when the list was generated, so half the year's occurrences land an hour off after a DST change. Store the rule, the local time, and the zone; expand occurrences at query time against current zone data.

Exception three: civil dates. Store plain dates as plain dates: 2026-11-03, with no time and no zone. A database DATE column, not a TIMESTAMP.

The three shapes side by side:

json
{
  "orderPlacedAt": "2026-09-26T14:30:12Z",
  "keynote": {
    "localStart": "2027-03-14T09:00",
    "timeZone": "Europe/Berlin"
  },
  "officeHours": {
    "rule": "FREQ=WEEKLY;BYDAY=MO",
    "localTime": "09:00",
    "timeZone": "Europe/Berlin"
  },
  "memberSince": "2019-06-01"
}

For transmission, the rule is ISO 8601 end to end: instants with Z or an explicit offset, local times with a zone identifier alongside, plain dates as dates. A locale-formatted string like "26/09/2026 14:30" is display output. It is never an interchange format, and it is never parsed back, because its field order and meaning depend on a locale the receiver cannot see.

Kind of timeExamplesStore asResolve to viewer's zone
InstantPayment, post, loginUTC ISO 8601 or epochAt display time
Future wall-clock eventMeeting, launch, appointmentLocal date-time plus IANA zoneAt display time, with current zone data
Recurring scheduleWeekly office hours, opening hoursRule plus local time plus IANA zoneExpand at query time
Plain dateBirthday, holiday, all-day eventDate onlyNever, it has no zone

Zones and DST are data, not arithmetic

A time zone reference has to survive rule changes, which rules out the two common shortcuts. Abbreviations are ambiguous: "CST" means different zones on different continents, and "IST" covers India, Ireland, and Israel. Fixed offsets like "UTC+1" are wrong twice a year anywhere that observes DST. The only stable reference is an identifier from the IANA time zone database: Europe/Berlin, America/Sao_Paulo, Asia/Kolkata. Most identifiers name a notable location; the database records that zone's clock transitions since 1970 and its current rules, while its pre-1970 entries are far from complete.

DST is why offset arithmetic fails. Adding 24 hours to a timestamp is not the same as adding one calendar day when a transition falls in between: the result lands early or late in local terms, usually by an hour. And transitions create local times that do not exist or occur twice. When clocks spring forward, some local times on that night never happen (2:30 in America/New_York or Europe/Berlin); when they fall back, some happen twice (1:30 in America/New_York, 2:30 in Europe/Berlin). Correct code computes through zone data, asking "what is 9:00 on this date in this zone," rather than adding hours to a UTC value.

This is also where tests earn their keep. Date logic that passes on an ordinary Tuesday fails on transition nights, so a date-handling test suite pins the clock to specific moments: the spring-forward night, the fall-back night, a month-end, a year-end, and a leap day, each in at least one zone that observes DST and one that does not. Run the suite with the process time zone set to something other than UTC, because code that only ever runs in UTC hides every local-zone assumption.

The database changes because rules are political. Countries abolish DST, adopt it, or move their standard offset, and the IANA maintainers publish updated releases as they do. Engines embed this data and refresh it through normal platform and runtime updates, although the tz database's own documentation notes that updates may take substantial time to reach end users after a release, and that older devices that are no longer supported may never be updated. That is the argument against hand-maintained offset tables in application code: they are a copy of a moving dataset with no update channel.

To detect the viewer's zone, the working default is the runtime's own answer:

javascript
const viewerZone = Intl.DateTimeFormat().resolvedOptions().timeZone; // e.g. "Europe/Lisbon"

const fmt = new Intl.DateTimeFormat(locale, {
  dateStyle: "medium",
  timeStyle: "short",
  timeZone: viewerZone,
});
fmt.format(new Date("2026-09-26T14:30:12Z"));

Treat detection as a suggestion. A traveling user's device zone is not always the zone they want to see, and where the product has an account-level time zone preference, that preference wins. The broader suggest-don't-force principle for locale signals belongs to the insight locale-detection literature.

Server, client, and the hydration mismatch

Server rendering adds a structural problem. The server renders in its own zone, often UTC, and a default locale. The browser then re-renders the same component in the viewer's zone and locale. The server's HTML says "14:30" and the client computes "16:30"; the framework detects the difference and reports a hydration mismatch, and a framework that attempts automatic recovery (Vue, for example) then adjusts the server-rendered DOM to match the client, which can appear as a visible flicker. This is the i18n flavor of hydration mismatch, and frameworks with server rendering, React and Vue among them, document a version of it.

Three resolutions work, each in a different architecture:

  1. Render zone-dependent values on the client only, after mount. The server emits a placeholder or the canonical ISO value; the client formats it. Simple and always consistent, at the cost of a brief layout shift and no formatted time in the initial HTML.
  2. Give the server the viewer's zone and locale. Persist the resolved zone in a cookie or account setting, read it on the server, and format with the same inputs on both sides. Correct first paint, but it depends on having the zone before the first render, which a first-time visitor's request does not carry.
  3. Render a stable canonical form and enhance it. Output a <time datetime="2026-09-26T14:30:12Z"> element with a neutral, zone-explicit label such as "14:30 UTC", then let the client replace the label with a local rendering. Accessible and robust, and it degrades gracefully without JavaScript.

Relative time needs its own decision, because "3 minutes ago" drifts with time itself as well as with zone. The server's "3 minutes ago" is already stale when the page hydrates. Either render relative times client-only, or render the absolute time on the server and upgrade it on the client with a refresh policy for long-lived pages.

The rule that generalizes: any value that depends on the viewer's zone or locale has exactly one computation authority per render. Either the server knows the inputs and computes it, or the client does. Both computing it with different inputs is the bug.

Date, Temporal, and what to build on today

JavaScript's Date causes bugs at this layer because it models only one of the three kinds of time. A Date is an instant whose getter methods read it in either the host's local zone or UTC. It has no plain-date type, so birthdays become midnight timestamps. It has no zoned date-time type, so a "9:00 in Berlin" event has no native representation. It is mutable, and its months are zero-indexed. Every exception in this article has to be modeled around it.

Temporal is the designed successor. It reached TC39 Stage 4 in March 2026 and is expected in the ES2027 edition of the language standard (TC39's finished-proposals list gives 2027 as its expected publication year). As of Nov 2026, Firefox and Chrome ship it, while MDN still lists Temporal as limited availability rather than Baseline because it does not yet work in all major browsers, and Safari had not shipped it in a stable release; MDN's compatibility data lists Safari support only in Safari Technology Preview (MDN). WebKit has been landing the implementation, so this is worth re-checking before relying on it. Using Temporal in production today is therefore a polyfill decision, with the polyfill's weight weighed against the audience that needs it.

What Temporal fixes is exactly this article's problem. It has distinct types for each kind of time: Temporal.Instant for points on the timeline, Temporal.PlainDate for civil dates, Temporal.PlainDateTime for wall-clock values without a zone, and Temporal.ZonedDateTime for a wall-clock time bound to a time zone (an IANA zone or a fixed UTC offset). Arithmetic on a ZonedDateTime is DST-aware by construction. The type system encodes the distinction that Date forces every team to maintain by convention.

The durable guidance does not depend on which API wins in a given runtime. Store instants in UTC. Store future events and recurring rules as local time plus an IANA zone. Store civil dates as dates. Transmit ISO 8601. Compute through zone data, never offsets. Give each zone-dependent value one computation authority. A team on Date plus Intl, one on a date library, and one on Temporal with a polyfill can implement exactly the same architecture. Non-Gregorian calendars exist and are reachable through locale data and calendar options, and for display they layer on top of the same stored values. Arithmetic or other calculations in months or years are calendar-sensitive, however, and Temporal's documentation calls it best practice to specify a calendar system when performing those operations.

Project Inquiry