Skip to content

isBetweenUnix

isBetweenUnix(value: number, start: number, end: number, options?: { epochUnit?: "seconds" | "milliseconds"; timeZone?: string; inclusiveStart?: boolean; inclusiveEnd?: boolean; }): boolean
import { isBetweenUnix } from "@northguild/gmt/unix/calculate";

Return true when the Unix timestamp is between start and end (inclusive by default).

  • Uses Temporal.Instant.compare for comparison.
  • Returns false if start > end or inputs are invalid.
  • Use options.inclusiveStart/inclusiveEnd to control boundaries.
Parameter Type Description
value number Unix timestamp to check
start number Unix timestamp for range start
end number Unix timestamp for range end

options

Option Type Default
epochUnit? "seconds" | "milliseconds"
timeZone? string
inclusiveStart? boolean
inclusiveEnd? boolean

boolean indicating whether value is between start and end

isBetweenUnix(1705000000000, 1704000000000, 1706000000000) // true
isBetweenUnix(1705000000, 1704000000, 1706000000, { epochUnit: "seconds" }) // true
isBetweenUnix(1703000000000, 1704000000000, 1706000000000) // false

unix/calculate/isBetweenUnix.ts