Fin del día en JavaScript
Obtengamos un objeto de fecha que contenga el fin del día actual:
let now = new Date();
let date = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 23, 59, 59);
Se puede considerar como fin del día actual la medianoche
del siguiente (diferencia de 1 segundo):
let now = new Date();
let date = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1, 0, 0, 0);
Como ya sabes, en este caso se pueden omitir los ceros:
let now = new Date();
let date = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1);
Por cierto, la medianoche también será la hora
24:00:00 del día actual:
let now = new Date();
let date = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 24, 0, 0);
Omitamos los ceros:
let now = new Date();
let date = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 24);
Determina cuántas horas quedan hasta el fin del día.