formatZonedRange
Signature
Section titled “Signature”formatZonedRange(from: string, to: string, locale?: string | string[], options?: DateTimeFormatOptions): stringFormat a zoned datetime range using the Temporal Intl.DateTimeFormat formatRange API.
- Both datetimes must have the same time zone: identifiers of one zone count as the same (
UTCandEtc/UTCon every host; an IANA link such asEurope/KievandEurope/Kyivwhere the host resolves it, which Safari 27 withoutTemporaldoes not). - Formats both instants as Temporal’s ECMA-402 Instant format does, through the runtime’s
Intl.DateTimeFormat#formatRangein the endpoints’ zone: the requested fields and widths are kept, and with no date or time field (eraalone included) the date and time are the defaults. - The requested
timeZoneNamestyle is kept, also on engines whose ICU drops it from ranges (ICU-20548), and a flexibledayPeriodnext to a zone name stays “in the morning” on engines that write AM/PM in ranges. - Returns "" for invalid input, mismatched timezones, or a
timeZoneoption (a ZonedDateTime keeps its own zone). - Compatibility: before 1.21.0 on V8 and JSC,
long,longGenericand the offset zone names came out short or missing in ranges, and on Firefox adayPeriodwith atimeZoneNamecame out as AM or PM. Before 1.16.0 some locales lost a requested width (zh-CN with{ year: "numeric", month: "long" }gave"2024/2"),eraalone dropped the time, and atimeZoneoption was silently overridden by the endpoints’ zone. Pass the fields the old text showed to keep it, and drop thetimeZoneoption to keep the endpoints’ zone. - Output is normalized: dash separators become ASCII ”-” (unspaced between digits, spaced otherwise), and no-break, narrow and thin spaces become U+0020.
optionsnull returns"", as ECMA-402’s CoerceOptionsToObject rejects it (a string or number options value formats with the defaults, asIntl.DateTimeFormatdoes).- On a runtime whose D33 probe fails, a
chineseordangicalendar returns""for any format with a year, month, day or era (compat D33). A format with only a time or weekday field still returns its text.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
from | string | zoned ISO 8601 datetime string (range start) |
to | string | zoned ISO 8601 datetime string (range end) |
locale | string | string[] | optional locale tag, or a preference list of tags (ECMA-402) |
Options
Section titled “Options”options
optional Intl.DateTimeFormatOptions
Type: DateTimeFormatOptions.
| Option | Type | Default | Description |
|---|---|---|---|
…Intl.DateTimeFormatOptions | — | — | Every field of DateTimeFormatOptions, as ECMA-402 defines it. |
Returns
Section titled “Returns”localized range string or "" when invalid
Related types
Section titled “Related types”Examples
Section titled “Examples”import { formatZonedRange } from "@northguild/gmt/zoned/format";
formatZonedRange("2024-02-29T12:00:00.000+00:00[UTC]", "2024-02-29T14:00:00.000+00:00[UTC]", "de-DE", { dateStyle: "long", timeStyle: "short" }) // "29. Februar 2024, 12:00-14:00 Uhr"Source
Section titled “Source”Accessibility
© 2026 NorthGuild · Licences
Code examples: MIT-0. Packages: MIT. Third-party data and components: their own licences, credited where they appear. Everything else: © 2026 NorthGuild, all rights reserved.