I am trying to do this kind of countdown:
Now it is 09:20 and I am wanna how many minutes and seconds has left to 1 hour. So it would take 40 minutes to 10:00.
This countdown has to continuously count this gap within the day.
I've tried the following but it didn't work:
var now = new Date();
var mins = now.getMinutes();
var secs = now.getSeconds();
function initClock(id) {
const counter = document.getElementById(id);
const minutesItem = counter.querySelector('.js-countdown-minutes');
const secondsItem = counter.querySelector('.js-countdown-seconds');
function updateClock() {
mins = now.getMinutes();
secs = now.getSeconds();
minutesItem.innerHTML = (60 - mins);
secondsItem.innerHTML = (secs);
}
updateClock();
const timeinterval = setInterval(updateClock, 1000);
}
initClock('js-countdown');
The Seconds aren't being updated.