Get the timezone string

Read the runtime’s IANA time zone, such as America/Sao_Paulo.

JavaScriptNode.js & browsers Version 1.0.0 · MIT · .md

get-the-timezone-string.js
function getTimezone() { return Intl.DateTimeFormat().resolvedOptions().timeZone; }

Usage

usage.js
getTimezone(); // e.g. 'America/Sao_Paulo'
const at = new Date('2026-10-28T12:00:00Z');
at.toLocaleTimeString('en-GB', { timeZone: 'America/Sao_Paulo', hour: '2-digit', minute: '2-digit' }); // → '09:00'
at.toLocaleTimeString('en-GB', { timeZone: getTimezone(), hour: '2-digit', minute: '2-digit' }); // e.g. '09:00'

Lines marked → were executed in Node.js 22 and in headless Chromium, and each result was compared with the value shown. Lines marked e.g. are illustrative.

Know the limits

  • Returns the zone of the runtime: the visitor’s in a browser, the server’s (often UTC) in Node.js. Store instants in UTC and convert for display.
  • A zone is not an offset: America/Sao_Paulo has had no daylight saving time since 2019, while other zones still shift twice a year.

The function above is the code the usage lines run. It does not validate its arguments; add checks where it receives untrusted input.

Source & maintenance

Based on Get the timezone string from the original 1loc collection by Nguyen Huu Phuoc. Copyright (c) 2020 phuoc-ng. MIT licensed.

Documented as a reference with executed usage lines. Original MDX retained as inert source evidence.

Maintained by Oveyon. Source commit: 14b481cf60df. Read the license.

Usage lines executed in Node.js 22 and headless Chromium; no external services · reviewed October 28, 2026.

Keep exploring

Type two or more characters. Try “duplicate”, “webhook” or “retry”.