Timestamp comparison helpers work with date-only, time-only, and date-time values.
import { function compareDate(ts1: Timestamp, ts2: Timestamp): booleanCompares the calendar date portion of two Timestamp objects.compareDate, function compareDateTime(ts1: Timestamp, ts2: Timestamp): booleanCompares the formatted date and time portions of two Timestamp objects.compareDateTime, function compareTime(ts1: Timestamp, ts2: Timestamp): booleanCompares the formatted time portion of two Timestamp objects.compareTime, function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp } from '@timestamp-js/core'
const const a: Timestampa = function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2026-06-08 09:30')!
const const b: Timestampb = function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2026-06-08 10:00')!
function compareDate(ts1: Timestamp, ts2: Timestamp): booleanCompares the calendar date portion of two Timestamp objects.compareDate(const a: Timestampa, const b: Timestampb)
function compareTime(ts1: Timestamp, ts2: Timestamp): booleanCompares the formatted time portion of two Timestamp objects.compareTime(const a: Timestampa, const b: Timestampb)
function compareDateTime(ts1: Timestamp, ts2: Timestamp): booleanCompares the formatted date and time portions of two Timestamp objects.compareDateTime(const a: Timestampa, const b: Timestampb)Ranges
Use range helpers when inclusive date boundaries matter.
import { isBetweenDates, isOverlappingDates, parseTimestamp } from '@timestamp-js/core'
const target = parseTimestamp('2026-06-08')!
const start = parseTimestamp('2026-06-01')!
const end = parseTimestamp('2026-06-30')!
isBetweenDates(target, start, end)
isOverlappingDates(start, end, target, target)Min and max
import { function maxTimestamp(timestamps: Timestamp[], useTime?: boolean): TimestampFinds the latest Timestamp in an array.maxTimestamp, function minTimestamp(timestamps: Timestamp[], useTime?: boolean): TimestampFinds the earliest Timestamp in an array.minTimestamp, function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp } from '@timestamp-js/core'
const const first: Timestampfirst = function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2026-06-08')!
const const second: Timestampsecond = function parseTimestamp(input: string, now?: Timestamp | null): Timestamp | nullConverts a supported date or date-time string into a formatted Timestamp object.
If `now` is supplied, the returned timestamp also includes relative flags
such as `past`, `current`, `future`, and `currentWeekday`.parseTimestamp('2026-06-09')!
function minTimestamp(timestamps: Timestamp[], useTime?: boolean): TimestampFinds the earliest Timestamp in an array.minTimestamp([const first: Timestampfirst, const second: Timestampsecond])
function maxTimestamp(timestamps: Timestamp[], useTime?: boolean): TimestampFinds the latest Timestamp in an array.maxTimestamp([const first: Timestampfirst, const second: Timestampsecond])