getTimeZoneOffset
Signature
Section titled “Signature”getTimeZoneOffset(timeZone: string, instant: string): stringimport { getTimeZoneOffset } from "@northguild/gmt/zoned/get";Return an IANA timeZone’s UTC offset at a given instant.
- Unlike
getZonedOffset, this doesn’t need an existing zoned value in hand — pass any timeZone identifier and an instant to look up, which is why (likegetDstTransitions) it lives inget/despite taking two arguments: neither is a date value being described, both are coordinates for a zone-level lookup. - Returns “” for an invalid timeZone or instant.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
timeZone |
string |
IANA timeZone identifier |
instant |
string |
ISO 8601 instant string (e.g. “2024-07-15T12:00:00Z”) |
Returns
Section titled “Returns”offset string (e.g. “-04:00”), or “” on invalid input
Related types
Section titled “Related types”Examples
Section titled “Examples”getTimeZoneOffset("America/New_York", "2024-07-15T12:00:00Z") // "-04:00"getTimeZoneOffset("America/New_York", "2024-01-15T12:00:00Z") // "-05:00"getTimeZoneOffset("Asia/Kathmandu", "2024-01-15T12:00:00Z") // "+05:45"getTimeZoneOffset("Invalid/Zone", "2024-07-15T12:00:00Z") // ""getTimeZoneOffset("America/New_York", "not an instant") // ""