Skip to content

getUnixNow

getUnixNow(options?: { epochUnit?: UnixUnit; }): number | null

Return the current Unix timestamp in either seconds or milliseconds.

  • Uses Temporal.Now.instant() to get current time.
  • An explicit undefined is the same as omitted. An unknown epochUnit, or a non-object options (such as a bare "seconds" string), returns null.

options

optional: the unit of the result

OptionTypeDefaultDescription
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.

the current unix timestamp, or null on invalid options

import { getUnixNow } from "@northguild/gmt/unix/get";
getUnixNow() // 1700000000000
output 

unix/get/getUnixNow.ts