Skip to content

parseTimeFromUnix

parseTimeFromUnix(value: number, options?: { epochUnit?: UnixUnit; timeZone?: string; }): string
import { parseTimeFromUnix } from "@northguild/gmt/unix/parse";

Extract the time portion from a unix epoch value.

  • Converts to ZonedDateTime then extracts the PlainTime.
  • Uses system timezone if not specified.
  • Returns “” for invalid input.
Parameter Type Description
value number unix epoch in milliseconds or seconds (number)

options

Option Type Default
epochUnit? UnixUnit
timeZone? string

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

parseTimeFromUnix(1700000000000) // "04:13:20"
parseTimeFromUnix(1700000000, { epochUnit: "seconds" }) // "04:13:20"
parseTimeFromUnix(-86400, { epochUnit: "seconds" }) // "00:00:00"

unix/parse/parseTimeFromUnix.ts