Get the UTC Offset for a Timezone in JavaScript
To get a zone's UTC offset at a moment, build a Temporal.ZonedDateTime in that zone and read .offset ('-04:00') or .offsetNanoseconds. Part of Timezone Offset Math Explained.
Why this scenario is tricky
An offset is not a property of a zone — it is a property of a zone at an instant, because DST moves it twice a year. Asking "what is New York's offset" is meaningless without a date; America/New_York is -05:00 in January and -04:00 in July. Read the offset off a zoned instant, not a lookup table.
Minimal working solution
import { Temporal } from '@js-temporal/polyfill';
const zdt = Temporal.Now.instant().toZonedDateTimeISO('America/New_York');
zdt.offset; // '-04:00' or '-05:00' depending on the date
Full production version
import { Temporal } from '@js-temporal/polyfill';
function offsetAt(instant: Temporal.Instant, zone: string) {
const z = instant.toZonedDateTimeISO(zone);
return { text: z.offset, minutes: z.offsetNanoseconds / 60e9 };
}
Verification snippet
Common pitfalls
Frequently Asked Questions
How do I get the UTC offset of a time zone in JavaScript?
Build a Temporal.ZonedDateTime for the instant you care about in that zone and read its offset ('-04:00') or offsetNanoseconds. The offset must be tied to an instant because daylight saving changes it during the year.
Why can't I store a single UTC offset for a time zone?
Because a zone has different offsets at different times — New York is -05:00 in winter and -04:00 in summer — so a stored number goes stale at the next DST transition. Store the IANA identifier and compute the offset per instant.