convertUnixToUtc
Signature
Section titled “Signature”convertUnixToUtc(value: string | number, options?: { epochUnit?: UnixUnit; }): stringConvert a unix epoch value to a UTC Instant ISO string.
- Converts to UTC Instant using Temporal.Instant.
valueis a safe integer or a string of optionally negative ASCII digits; anything else, or an instant outside the Temporal range, returns "".- An explicit
undefinedoptionsis the same as omitted; a non-objectoptions(such as a bare"seconds"string) returns "".
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | string | number | epoch value: a safe integer or a digit string |
Options
Section titled “Options”options
optional: how value is read
| Option | Type | Default | Description |
|---|---|---|---|
epochUnit? | "seconds" | "milliseconds" | "second" | "millisecond" (UnixUnit) | "milliseconds" | The unit the epoch values are counted in: "seconds" or "milliseconds", singular or plural. Any other value returns "". |
Returns
Section titled “Returns”UTC Instant string or "" on invalid
Related types
Section titled “Related types”Examples
Section titled “Examples”import { convertUnixToUtc } from "@northguild/gmt/unix/convert";
convertUnixToUtc(1709164800000) // "2024-02-29T00:00:00Z"