parseDateFromUnix
Signature
Section titled “Signature”parseDateFromUnix(value: number, options?: { epochUnit?: UnixUnit; timeZone?: string; }): stringimport { parseDateFromUnix } from "@northguild/gmt/unix/parse";Extract the date portion from a unix epoch value.
- Converts to ZonedDateTime then extracts the PlainDate.
- Uses system timezone if not specified.
- Returns “” for invalid input.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value |
number |
unix epoch in milliseconds or seconds (number) |
Options
Section titled “Options”options
| Option | Type | Default |
|---|---|---|
epochUnit? |
UnixUnit |
— |
timeZone? |
string |
— |
Returns
Section titled “Returns”ISO date string (e.g., “2024-03-17”) or “” on invalid input
Related types
Section titled “Related types”Examples
Section titled “Examples”parseDateFromUnix(1700000000000) // "2023-11-15"parseDateFromUnix(1700000000, { epochUnit: "seconds" }) // "2023-11-15"parseDateFromUnix(-86400, { epochUnit: "seconds" }) // "1969-12-31"