Skip to content

Function.isSame

github-actions[bot] edited this page Aug 6, 2026 · 22 revisions

umt / isSame

Function: isSame()

isSame(left, right, unit?): boolean

Defined in: Date/isSame.ts:18

Returns true when two dates are the same at the given unit granularity. Without a unit, compares exact timestamps (millisecond precision). With a unit, both dates are truncated with startOf before comparison. Week boundaries follow Sunday-start local time, matching startOf.

Parameters

left

Date

First date

right

Date

Second date

unit?

DateBoundaryUnit

Granularity; omit for exact equality

Returns

boolean

True when the dates match at the given granularity

Example

isSame(new Date(2025, 3, 15, 1), new Date(2025, 3, 15, 23), "day"); // true
isSame(new Date(2025, 3, 15), new Date(2025, 4, 15), "month"); // false
isSame(new Date(2025, 0, 1), new Date(2025, 0, 1)); // true

API

Classes

Interfaces

Type Aliases

Variables

Functions

Clone this wiki locally