Why not reset the timer in js?

Doing the countdown, faced with magic, when you refresh the page the timer is not reset why
start googling all the problem is exactly the turnover - what's the matter? how to do that would refresh the page the timer is started on a new one?
var now = new Date(),
 times = [
 0 - now.getHours(),
 25 - now.getMinutes(),
 59 - now.getSeconds(),
],
 mBox = document.getElementById('minutes'),
 sBox = document.getElementById('seconds');
clearInterval(times)
timer_live(times);

 timer_live function(times) {
 var tm = setInterval(function () {
 var hour = times[0],
 min = times[1],
 sec = times[2];

times[2]--;

 if (times[0] == 0 && times[1] == 0 && times[2] == 0) {
clearInterval(tm);
 } else if (times[2] == -1) {
times[1]--;
 times[2] = 59;
 } else if (times[1] == -1) {
times[0]--;
 times[1] = 59;
}

 var hour = (times[0] < 10) ? '0' + times[0] : times[0],
 min = (times[1] < 10) ? '0' + times[1] times[1],
 sec = (times[2] < 10) ? '0' + times[2] times[2];

 showTimer(hour, min, sec);
 }, 1000);
};

 function showTimer(hour, min, sec) {
 mBox.innerHTML = min;
 sBox.innerHTML = sec;
 }
April 7th 20 at 10:57
2 answers
April 7th 20 at 10:59
Solution
You clearInterval(times) will not reset the timer, because the argument you have to specify the array times, and the result is tmreturned by the function tm = setInterval(...);.
And in General the code is working, you just have to count down the 25 minute times on the other to initialize: times = [0, 25,0],.

Maybe you have the document there are no items
<span id=hBox>00</span>:<span id=mBox>00</span>:<span id=sBox>00</span>
? - Erna commented on April 7th 20 at 11:02
April 7th 20 at 11:01
Probably because the initial value of the timer you have is tied to the current time

var now = new Date(),
 times = [
 0 - now.getHours(),
 25 - now.getMinutes(),
 59 - now.getSeconds(),
 ],


UPDATE

in addition, the line clearInterval(times) does not work as you might expect. She needed to cancel the interval timer. Takes as input the id of the timer, you're passing an array with the timer value.
Duck me and it is necessary that each time when I loaded the page, it measured 25 minutes ago and all.
Every time it is up to date - I see no contradiction here - Tanner69 commented on April 7th 20 at 11:04
@Tanner69, something we lost in the logic. Can describe in detail what you want to achieve? - Serena_Nikolaus commented on April 7th 20 at 11:07

Find more questions by tags JavaScript