I have a page with a countdown. Where will show the time that is missing for a certain thing. It's working perfectly. However, I would like to include one more variable. In case the month . That is, before the normal time that is shown nowadays, I would like to include how many days are missing for a certain thing.
var countDownDate = new Date("Sep 26, 2017 23:00:00").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);
// Display the result in the element with id="demo"
document.getElementById("demo").innerHTML = hours + "h " +
minutes + "m " + seconds + "s ";
// If the count down is finished, write some text
if (distance < 0) {
clearInterval(x);
document.getElementById("demo").innerHTML = "<a href='https://www.youtube.com/watch?v=5VhQubIDiRk'>Clica aqui</a><br>Espero que goste.";
}
}, 1000);
<h1></h1>
<!-- YOUR TITLE HERE -->
<!-- Display the countdown timer in an element -->
<div class="text">Contagem regressiva para a segunda temporada</div>
<p id="demo"></p>
<div class="message">teste</div>