Skip to content

convertUtcToPlainTime

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

Convert a UTC datetime string to a plain time string in the format “HH:mm:ss”.

  • Converts to specified timezone before extracting time.
  • Defaults to UTC if no timezone specified.
  • Returns “” for invalid input.
Parameter Type Description
value string UTC datetime string (e.g., “2024-02-29T00:00:00Z”)

options

Option Type Default
timeZone? string

plain time string in “HH:mm:ss” format or “” on invalid input

convertUtcToPlainTime("2024-02-29T00:00:00Z") // "00:00:00"
convertUtcToPlainTime("2024-02-29T00:00:00Z", { timeZone: "America/New_York" }) // "19:00:00"
convertUtcToPlainTime("invalid") // ""

utc/convert/convertUtcToPlainTime.ts