Answer the question
In order to leave comments, you need to log in
Timer output correction?
Now it displays the time in this format
3:50:39
03:50:39 or 05:05:05 is required, that is, if the number is not decimal, it should be before the number 0
var now = Date.now();
var distance = date - now;
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
Answer the question
In order to leave comments, you need to log in
For inspiration:
for (let i = 8; i < 13; i++) console.log( ('00' + i).substr(-2));
/* выведет:
08
09
10
11
12
*/
for (let i = 8; i < 13; i++) console.log( i.toString().padStart(2, '0'));
// тот же результат
String.padStart()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question