getUnixNow
Signature
Section titled “Signature”getUnixNow(options?: { epochUnit?: UnixUnit; }): number | nullReturn the current Unix timestamp in either seconds or milliseconds.
- Uses Temporal.Now.instant() to get current time.
- An explicit
undefinedis the same as omitted. An unknownepochUnit, or a non-objectoptions(such as a bare"seconds"string), returns null.
Options
Section titled “Options”options
optional: the unit of the result
| Option | Type | Default | Description |
|---|---|---|---|
epochUnit? | "seconds" | "milliseconds" | "second" | "millisecond" (UnixUnit) | "milliseconds" | The unit of the returned epoch: "seconds" or "milliseconds", singular or plural. Seconds floor toward −∞, as POSIX time_t counts whole elapsed seconds. Any other value returns null. |
Returns
Section titled “Returns”the current unix timestamp, or null on invalid options
Related types
Section titled “Related types”Examples
Section titled “Examples”import { getUnixNow } from "@northguild/gmt/unix/get";
getUnixNow() // 1700000000000