Skip to content

isValidUnixMilliseconds

isValidUnixMilliseconds(timestamp: unknown): boolean
import { isValidUnixMilliseconds } from "@northguild/gmt/unix/validate";

Return true when timestamp is a valid Unix milliseconds value.

  • Must be an integer (positive or negative, for dates before/after 1970).
  • Returns false for non-numbers or non-integers.
Parameter Type Description
timestamp unknown number candidate

boolean indicating whether the timestamp is a valid Unix milliseconds value

isValidUnixMilliseconds(1700000000000) // true
isValidUnixMilliseconds(-86400000) // true (1969-12-31)
isValidUnixMilliseconds(1.5) // false

unix/validate/isValidUnixMilliseconds.ts