Skip to content

formatZonedRange

  • The core functions, which every industry uses.
formatZonedRange(from: string, to: string, locale?: string | string[], options?: DateTimeFormatOptions): string

Format 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 (UTC and Etc/UTC on every host; an IANA link such as Europe/Kiev and Europe/Kyiv where the host resolves it, which Safari 27 without Temporal does not).
  • Formats both instants as Temporal’s ECMA-402 Instant format does, through the runtime’s Intl.DateTimeFormat#formatRange in the endpoints’ zone: the requested fields and widths are kept, and with no date or time field (era alone included) the date and time are the defaults.
  • The requested timeZoneName style is kept, also on engines whose ICU drops it from ranges (ICU-20548), and a flexible dayPeriod next to a zone name stays “in the morning” on engines that write AM/PM in ranges.
  • Returns "" for invalid input, mismatched timezones, or a timeZone option (a ZonedDateTime keeps its own zone).
  • Compatibility: before 1.21.0 on V8 and JSC, long, longGeneric and the offset zone names came out short or missing in ranges, and on Firefox a dayPeriod with a timeZoneName came 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"), era alone dropped the time, and a timeZone option was silently overridden by the endpoints’ zone. Pass the fields the old text showed to keep it, and drop the timeZone option 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.
  • options null returns "", as ECMA-402’s CoerceOptionsToObject rejects it (a string or number options value formats with the defaults, as Intl.DateTimeFormat does).
  • On a runtime whose D33 probe fails, a chinese or dangi calendar 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.
ParameterTypeDescription
fromstringzoned ISO 8601 datetime string (range start)
tostringzoned ISO 8601 datetime string (range end)
localestring | string[]optional locale tag, or a preference list of tags (ECMA-402)

options

optional Intl.DateTimeFormatOptions

Type: DateTimeFormatOptions.

OptionTypeDefaultDescription
…Intl.DateTimeFormatOptions——Every field of DateTimeFormatOptions, as ECMA-402 defines it.

localized range string or "" when invalid

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"
output 

zoned/format/formatZonedRange.ts

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.