Skip to content

getZonedNow

getZonedNow(ianaTimezone: string, optionsArg?: { smallestUnit?: Temporal.ZonedDateTimeToStringOptions; }): string
import { getZonedNow } from "@northguild/gmt/zoned/get";

Return the current zoned datetime for the specified IANA timeZone.

  • Uses Temporal.Now.zonedDateTimeISO to get the current time.
  • Validation is performed on the timezone.
Parameter Type Description
ianaTimezone string IANA timeZone identifier

options

Option Type Default
smallestUnit? Temporal.ZonedDateTimeToStringOptions

zoned ISO 8601 datetime string or “” on invalid input

getZonedNow("America/New_York") // "2024-02-29T09:30:45.123-05:00[America/New_York]"
getZonedNow("Invalid/Zone") // ""

zoned/get/getZonedNow.ts