getUnixNowUnit
Signature
Section titled “Signature”getUnixNowUnit(unit: any): stringimport { getUnixNowUnit } from "@northguild/gmt/unix/get";Return the requested unit value from the current Unix timestamp in UTC.
- Valid units: “year”, “month”, “week”, “day”, “dayOfWeek”, “hour”, “minute”, “second”, “millisecond”, “microsecond”, “nanosecond”.
- Uses Temporal.Now.instant() converted to UTC zoned date time.
- Returns “” on invalid unit or failure.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
unit |
any |
unit to extract from current unix timestamp |
Returns
Section titled “Returns”string representation of the requested unit or “” on invalid
Related types
Section titled “Related types”Examples
Section titled “Examples”getUnixNowUnit("year") // "2024"getUnixNowUnit("month") // "02"getUnixNowUnit("invalid") // ""