isSameDay()
isSameDay(
date1
,date2
):null
|boolean
Defined in: src/utils/dateUtils.ts:73
Checks if two Date
objects fall on the same calendar day.
This function compares the year, month, and day parts of the two dates and ignores the time.
Parameters
date1
Date
The first date to compare.
date2
Date
The second date to compare.
Returns
null
| boolean
true
if both dates are on the same day, false
if not. Returns null
if either date is invalid.
Example
tsx
const date1 = new Date('2024-11-18T10:00:00Z');
const date2 = new Date('2024-11-18T23:59:59Z');
isSameDay(date1, date2); // true
isSameDay(new Date(), new Date('2024-11-19')); // false