convertUnixToUtc
Signature
Section titled “Signature”convertUnixToUtc(value: number, unit?: UnixUnit): stringimport { convertUnixToUtc } from "@northguild/gmt/unix/convert";Convert a unix epoch value to a UTC Instant ISO string.
- Converts to UTC Instant using Temporal.Instant.
- Validates value and epoch unit (“seconds” | “milliseconds”).
- Returns “” for invalid input.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value |
number |
epoch value (number) |
unit |
`` | optional unit, “seconds” or “milliseconds” |
Returns
Section titled “Returns”UTC Instant string or “” on invalid
Related types
Section titled “Related types”Examples
Section titled “Examples”convertUnixToUtc(1709164800000) // "2024-02-29T00:00:00Z"convertUnixToUtc(1709164800, "seconds") // "2024-02-29T00:00:00Z"convertUnixToUtc(-1) // "1969-12-31T23:59:59.999Z"