There is a script that calculates the time until tomorrow. Under each line I wrote comments. I do not understand how the number of minutes is calculated: (seconds % 3600) / 60 . And number of seconds: (seconds % 3600) % 60 .
var tomorrow = new Date().setHours(24, 0, 0); (function foo() { var now = new Date(); // Сколько секунд осталось до завтра. var seconds = parseInt(tomorrow - now) / 1000; // 3600 - кол-во секунд в часе. Сколько часов осталось до завтра var hh = parseInt( seconds / 3600 ); // var mm = parseInt( (seconds % 3600) / 60 ); var ss = parseInt( (seconds % 3600) % 60 ); document.body.innerHTML = hh + ":" + mm + ":" + ss ; setTimeout(foo, 1000); })();