Skip to content

Function.isBetween

github-actions[bot] edited this page Aug 19, 2026 · 18 revisions

umt / isBetween

Function: isBetween()

isBetween(date, start, end, unit?, inclusivity?): boolean

Defined in: Date/isBetween.ts:21

Returns true when date lies between start and end. Without a unit, compares exact timestamps. With a unit, all three dates are truncated with startOf first. Week boundaries follow Sunday-start local time, matching startOf. Ranges are not swapped: if start is after end, the result is false.

Parameters

date

Date

Date to test

start

Date

Range start

end

Date

Range end

unit?

DateBoundaryUnit

Granularity; omit for exact comparison

inclusivity?

DateInclusivity = "()"

Bound inclusivity

Returns

boolean

True when the date is between the bounds

Example

isBetween(new Date(2025, 3, 15), new Date(2025, 3, 10), new Date(2025, 3, 20));
isBetween(start, start, end, undefined, "[]"); // true

API

Classes

Interfaces

Type Aliases

Variables

Functions

Clone this wiki locally