0
I need an equal contact has on these promotion sites, type promotion ends in x days, so I want when it zeroes, example: 00:00:00 it counts 2 days ( or 1 day) forward 48:00:00 and starts the countdown again
<span id="demo"></span>
// Set the date we're counting down to
var countDownDate = new Date("Octo 21 , 2019 19:37:25").getTime();
// Update the count down every 1 second
var x = setInterval(function() {
// Get todays date and time
var now = new Date().getTime();
// Find the distance between now an the count down date
var distance = countDownDate - now;
// Time calculations for days, hours, minutes and seconds
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);
// Output the result in an element with id="demo"
document.getElementById("demo").innerHTML = days + " : " + hours + " : "
+ minutes + " : " + seconds + "";
// If the count down is over, write some text
if (distance < 0) {
clearInterval(x);
document.getElementById("demo").data = data + 1;
}
I understand that you are looking for something ready, to just add to your project. I don’t know if you’ve done this yet, but search for funcao Countdown javascript on google. You will find templates ready to adapt your need. In order to make it wait 2 days to re-display the countdown, you must save the Date/Time of the start of the countdown in the cache, cookie, file, etc.
– Christiano Ribeiro Soares
So I guess you don’t need to keep the count in the cache, as soon as it zeroes it will add 2 more days, getting 48:00:00, and counting down again
– dev2 pecaagora