const now = Date.now();
const day = 1000 * 60 * 60 * 24;
let checkpoint = now - (now % day) + day;
function tick() {
const time = new Date(checkpoint - Date.now());
if (time < 0) {
time += day;
checkpoint += day;
}
console.log(time.toTimeString().slice(0, 8));
}
function loop() {
tick();
setTimeout(loop, 1000);
}
loop();