Use IANA time-zone identifiers when JavaScript needs a named region such as Asia/Kolkata, Europe/Paris or America/Los_Angeles. A named zone is more useful than a fixed UTC offset because regional daylight-saving and historical rules can change the effective offset.
const zones = Intl.supportedValuesOf("timeZone");
The list below is generated by the server's IANA time-zone database. You can copy it directly into JavaScript.
Where supported, Intl.supportedValuesOf("timeZone") returns the time-zone identifiers recognized by the JavaScript runtime.
const zones = Intl.supportedValuesOf("timeZone");
console.log(zones.length);
console.log(zones[0]);
const select = document.querySelector("#timeZone");
const zones = Intl.supportedValuesOf("timeZone");
for (const zone of zones) {
const option = document.createElement("option");
option.value = zone;
option.textContent = zone;
select.append(option);
}
const formatter = new Intl.DateTimeFormat(undefined, {
timeZone: "Asia/Kolkata",
dateStyle: "medium",
timeStyle: "long"
});
console.log(formatter.format(new Date()));
America/New_York cannot be safely replaced with one permanent numeric offset because its offset changes during daylight-saving transitions. A zone identifier lets the runtime apply the correct rules for the date being formatted.
If Intl.supportedValuesOf() is unavailable in an older environment, ship a known list or generate one on the server. The copyable list above is generated with PHP's timezone_identifiers_list().
const zones = Intl.supportedValuesOf
? Intl.supportedValuesOf("timeZone")
: fallbackTimeZones;
See the live JavaScript time-zone clock.
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.