convertUnixToZoned
Signature
Section titled “Signature”convertUnixToZoned(value: number, timeZone: string, unit?: UnixUnit): stringimport { convertUnixToZoned } from "@northguild/gmt/unix/convert";Convert a unix epoch value to a zoned ISO 8601 datetime string.
- Converts to ZonedDateTime using the specified timezone.
- Validates value, timezone, and epoch unit.
- Returns “” for invalid input.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value |
number |
epoch value (number) |
timeZone |
string |
IANA timeZone identifier |
unit |
`` | optional unit, “seconds” or “milliseconds” |
Returns
Section titled “Returns”zoned ISO 8601 string or “” on invalid
Related types
Section titled “Related types”Examples
Section titled “Examples”convertUnixToZoned(1709164800000, "America/New_York") // "2024-02-29T00:00:00-05:00[America/New_York]"convertUnixToZoned(1709164800, "UTC", "seconds") // "2024-02-29T00:00:00+00:00[UTC]"convertUnixToZoned(-1, "UTC") // "1969-12-31T23:59:59.999Z[UTC]"