startOfDay()
startOfDay(
input):Date
Defined in: utils/date/startEndOfDay.ts:29
Get the start 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 to00:00:00.000local 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 midnight (00:00:00.000) 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, 15, 30, 45, 123); // 2024-01-10 15:30:45.123
const start = startOfDay(d);
// start -> 2024-01-10 00:00:00.000 (local time)