endOfDay()
endOfDay(
input):Date
Defined in: utils/date/startEndOfDay.ts:68
Get the end of the day (local time) for a given date-like value.
This helper:
- Accepts
Date, ISO-likestring, or timestampnumber. - Converts the value via toDateStrict.
- Returns a new
Dateinstance set to23:59:59.999local time. - Never mutates the input
Date.
Parameters
input
Date-like value representing the day you want to normalize.
string | number | Date
Returns
Date
A new Date object at local end-of-day (23:59:59.999) of that day.
Throws
When input cannot be converted into a valid Date (as determined by toDateStrict).
Example
ts
const d = new Date(2024, 0, 10, 5, 0, 0); // 2024-01-10 05:00:00
const end = endOfDay(d);
// end -> 2024-01-10 23:59:59.999 (local time)