The base date as a Date object or timestamp (number)
A new Date object set to 23:59:59.999 of the same date, or Invalid Date if input is invalid
// Get end of day from afternoon
const result = endOfDay(new Date(2024, 5, 15, 14, 30, 45, 123));
// Returns: June 15, 2024 23:59:59.999
// Works with start of day time
const result2 = endOfDay(new Date(2024, 5, 15, 0, 0, 0, 0));
// Returns: June 15, 2024 23:59:59.999
// Works with timestamps
const timestamp = Date.now();
const result3 = endOfDay(timestamp);
// Returns: End of today (23:59:59.999)
// Handles month boundaries
const result4 = endOfDay(new Date(2024, 5, 30, 9, 15));
// Returns: June 30, 2024 23:59:59.999
// Invalid inputs return Invalid Date
const result5 = endOfDay(new Date(NaN));
// Returns: Invalid Date
Get the end of the day for the given date.
This function returns a new Date object set to the last moment of the day (23:59:59.999) for the given date. The date remains the same while all time components are set to their maximum values.