getNowUnit
Signature
Section titled “Signature”getNowUnit(unit: any): stringimport { getNowUnit } from "@northguild/gmt/plain/get";Return the requested current unit value using the system timeZone.
- Valid units: “year”, “month”, “week”, “day”, “dayOfWeek”, “hour”, “minute”, “second”, “millisecond”, “microsecond”, “nanosecond”.
- Uses Temporal.Now.zonedDateTimeISO to get current time in system timezone.
- Returns “” when unit is invalid or system timezone is unavailable.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
unit |
any |
unit to extract from current local time |
Returns
Section titled “Returns”string representation of the requested unit or “” on invalid
Related types
Section titled “Related types”Examples
Section titled “Examples”getNowUnit("year") // "2024"getNowUnit("month") // "03"getNowUnit("week") // "11"getNowUnit("day") // "15"getNowUnit("dayOfWeek") // "5"getNowUnit("hour") // "14"getNowUnit("minute") // "30"getNowUnit("second") // "45"getNowUnit("millisecond") // "000"getNowUnit("microsecond") // "000"getNowUnit("nanosecond") // "000"getNowUnit("invalid") // ""