Sub topic 9
Time Zones and IANA Identifiers
This chapter assumes you know what Temporal.Instant represents and can build it from an ISO 8601 string. You should also know the Plain types from earlier chapters. Every example uses the global Temporal object, either native or from the polyfill.
What a Time Zone Is in Temporal
A time zone is a set of rules. It maps each exact instant to a UTC offset, and through that offset to a wall-clock time. The offset is the amount you add to UTC to get local time, such as -04:00 or +05:30. The rules hold the whole history of that region: when daylight saving time starts and ends, and every time a government moved its clocks.
This is why an offset is not a time zone. -05:00 tells you how one moment relates to UTC. America/New_York tells you that the offset is -05:00 in January, -04:00 in July, and something different again in 1945.
IANA Identifiers
Temporal names time zones with identifiers from the IANA Time Zone Database, also called tzdata or the Olson database. Most identifiers have the form Area/Location, such as Europe/Paris, Asia/Tokyo, or America/Argentina/Buenos_Aires. The location is usually the biggest city in a region that has shared the same clock history since 1970.
In current Temporal, time zones are plain strings. Early drafts had a Temporal.TimeZone class, but it was removed before the proposal was finalized. You pass identifiers wherever a time zone is needed, and you read them back from the timeZoneId property.
| Identifier kind | Example | Has DST rules | Notes |
|---|---|---|---|
| Named IANA zone | `America/New_York` | Yes, where the region uses DST | The normal choice for user-facing times |
| UTC | `UTC` | No | Fixed `+00:00` |
| Offset zone | `+05:30` | No | Fixed offset, minute precision only |
| Legacy link | `Asia/Calcutta` | Same as its target | Alias of `Asia/Kolkata` |
The next example converts one instant into several zones:
const instant = Temporal.Instant.from('2024-07-01T12:00:00Z');
const zones = ['UTC', 'America/New_York', 'Asia/Kolkata', 'Australia/Lord_Howe', '+05:30'];
for (const tz of zones) {
const zdt = instant.toZonedDateTimeISO(tz);
console.log(tz.padEnd(20), zdt.offset, zdt.toPlainTime().toString());
}
// UTC +00:00 12:00:00
// America/New_York -04:00 08:00:00
// Asia/Kolkata +05:30 17:30:00
// Australia/Lord_Howe +10:30 22:30:00
// +05:30 +05:30 17:30:00Offsets don't have to be whole hours. India uses +05:30, Nepal uses +05:45, and Lord Howe Island switches between +10:30 and +11:00, so its DST shift is only 30 minutes. Never assume offsets are whole hours or that DST moves clocks by exactly one hour.
Case Normalization and Links
Identifiers are case-insensitive. Temporal accepts any casing and stores the casing used by the database:
const zdt = Temporal.ZonedDateTime.from('2024-07-01T12:00[america/new_york]');
console.log(zdt.timeZoneId); // 'America/New_York'Links are older names that point to a current zone. Temporal keeps the name you gave it instead of swapping in the primary name. Equality checks still treat a link and its target as the same zone:
const a = Temporal.ZonedDateTime.from('2024-07-01T12:00[Asia/Calcutta]');
const b = Temporal.ZonedDateTime.from('2024-07-01T12:00[Asia/Kolkata]');
console.log(a.timeZoneId); // 'Asia/Calcutta'
console.log(a.equals(b)); // trueFinding and Validating Zones
Temporal.Now.timeZoneId() returns the system's current time zone. In a browser that is the user's zone. On a server it is often UTC, which is a common source of bugs when code reads "the local zone" on the server.
console.log(Temporal.Now.timeZoneId()); // for example 'Europe/Berlin'
// The runtime's list of primary identifiers, useful for a picker UI
const all = Intl.supportedValuesOf('timeZone');
console.log(all.includes('Asia/Tokyo')); // trueAn unknown identifier throws a RangeError. To validate user input, try to use the identifier and catch that specific error:
function isValidTimeZone(id) {
try {
Temporal.Instant.fromEpochMilliseconds(0).toZonedDateTimeISO(id);
return true;
} catch (e) {
if (e instanceof RangeError) return false;
throw e;
}
}
console.log(isValidTimeZone('Europe/Paris')); // true
console.log(isValidTimeZone('Mars/Olympus')); // false
console.log(isValidTimeZone('PST')); // falseDon't check against Intl.supportedValuesOf for validation. That list omits links such as Asia/Calcutta and offset zones such as +05:30, but Temporal accepts both.
Common Errors
Using abbreviations
PST, CEST, and IST are display abbreviations, not identifiers, and most of them are ambiguous: IST can mean India, Ireland, or Israel. A few, such as EST, are valid identifiers for historical reasons, and they are a trap. EST is a fixed -05:00 with no daylight saving:
const t = '2024-07-01T12:00';
console.log(Temporal.ZonedDateTime.from(`${t}[EST]`).offset); // '-05:00'
console.log(Temporal.ZonedDateTime.from(`${t}[America/New_York]`).offset); // '-04:00'Storing an offset instead of a zone
If you save 2024-03-01T09:00-05:00 for a recurring New York meeting, the offset is right in March but wrong after the DST change. Store the IANA identifier whenever you will compute other dates from the value later.
Assuming the rules never change
Governments change time zone rules, sometimes with only weeks of notice. Runtimes ship tzdata through ICU, so a Node.js or browser update can change the offset that a future local time maps to. For a future event that people attend in person, store the wall-clock time plus the zone, and work out the instant when you need it.
Inspecting Transitions
A ZonedDateTime can find the next or previous rule change in its zone. This helps with debugging and with building calendar UIs:
const jan = Temporal.ZonedDateTime.from('2024-01-01T00:00[America/New_York]');
const next = jan.getTimeZoneTransition('next');
console.log(next.toString()); // '2024-03-10T03:00:00-04:00[America/New_York]'
const fixed = Temporal.ZonedDateTime.from('2024-01-01T00:00[UTC]');
console.log(fixed.getTimeZoneTransition('next')); // nullThe result is the first instant after the transition, shown in the new offset. Zones with no transitions, such as UTC and offset zones, return null.
Exercise
A user in Mumbai enters the time zone "IST", and your app should show a meeting at 2024-07-01T12:00:00Z in their local time. What goes wrong, and what should the code use instead?
Show answer
"IST" is an ambiguous abbreviation (India, Ireland, or Israel), and it is not a valid IANA identifier, so Temporal throws a RangeError. Use "Asia/Kolkata", for example from a picker built with Intl.supportedValuesOf('timeZone'). Then Temporal.Instant.from('2024-07-01T12:00:00Z').toZonedDateTimeISO('Asia/Kolkata') gives 17:30 at offset +05:30.
Exercise
You store a weekly 09:00 meeting as the offset zone "-05:00" for a team in New York. What happens to the meeting's New York wall-clock time in July, and how do you fix it?
Show answer
A fixed -05:00 offset ignores daylight saving. In July New York is at -04:00, so 09:00 at -05:00 shows up as 10:00 local time. Store the identifier "America/New_York" with the 09:00 wall-clock time, and the offset will follow the zone's rules.