I want to make a cooldown that when I reach the end of for example 24h add 1 day and start the countdown again of 24h, if someone could help me I would be very grateful, thanks in advance Here something of what I've done trying:
var countDownYear = new Date().getFullYear();
var countDownMonth = new Date().getMonth() + 1;
var countDownDay = new Date().getDate();
var countDownDate = new Date(countDownMonth + " " + countDownDay + ", " + countDownYear + " 15:27:30").getTime();
var x = setInterval(function () {
var now = new Date().getTime();
var distance = countDownDate - 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);
document.querySelector('#daily-time').innerHTML = days + "d " + hours + "h " +
minutes + "m " + seconds + "s";
if (distance < 0) {
console.log(countDownDay);
countDownDay++;
console.log(countDownDay);
clearInterval(x);
}
}, 1000);
<div id="daily-time"></div>