parseYearFromUnix
Signature
Section titled “Signature”parseYearFromUnix(value: string | number, options?: { epochUnit?: UnixUnit; timeZone?: string; }): stringimport { parseYearFromUnix } from "@northguild/gmt/unix/parse";Return the year from a unix epoch value.
- Delegates to {@link parseUnitFromUnix} with unit “year”.
- Returns “” for invalid input.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value |
string | number |
unix epoch in milliseconds or seconds (number or string) |
Options
Section titled “Options”options
| Option | Type | Default |
|---|---|---|
epochUnit? |
UnixUnit |
— |
timeZone? |
string |
— |
Returns
Section titled “Returns”Year (YYYY) or “” on invalid input
Related types
Section titled “Related types”Examples
Section titled “Examples”parseYearFromUnix(1700000000000) // "2023"parseYearFromUnix(1704067200000, { epochUnit: "milliseconds" }) // "2024"parseYearFromUnix(-86400, { epochUnit: "seconds" }) // "1969"