Skip to content

parseTimeFromUtc

parseTimeFromUtc(value: string, options?: { timeZone?: string; }): string
import { parseTimeFromUtc } from "@northguild/gmt/utc/parse";

Extract the time portion from a UTC datetime string.

  • Uses Temporal.Instant.from to parse, converts to specified timezone.
  • Defaults to UTC if no timezone specified.
  • Returns “” for invalid input.
Parameter Type Description
value string ISO UTC datetime string (e.g., “2024-03-17T14:30:45Z”)

options

Option Type Default
timeZone? string

ISO time string (e.g., “14:30:45”) or “” on invalid input

parseTimeFromUtc("2024-03-17T14:30:45Z") // "14:30:45"
parseTimeFromUtc("2024-03-17T14:30:45Z", { timeZone: "America/New_York" }) // "10:30:45"
parseTimeFromUtc("invalid") // ""

utc/parse/parseTimeFromUtc.ts