Count Down
Time left for
Feb 22, 2025, 8:30:30AM
Structure
<p>Time left for <br><b>Feb 22, 2020, 8:30:30AM</b></p>
<br><br>
<h1 id="timer"></h1>
Process
<script type="text/javascript">
// Set the date we're counting down to
var countDownDate = new Date("Feb 22 2020 8:30:30").getTime();
var aSecond=1000,
aMinute=aSecond*60,
anHour=aMinute*60,
aDay=anHour*24;
// Update the count down every 1 second
var countdown = setInterval(function() {
// Get todays time in milliseconds
var now = new Date().getTime();
// Time difference between now and the count down date
var timeDifference = countDownDate - now;
// Time calculations for days, hours, minutes and seconds
var days = Math.floor(timeDifference / aDay);
var hours = Math.floor((timeDifference % aDay) / anHour);
var minutes = Math.floor((timeDifference % anHour) / aMinute);
var seconds = Math.floor((timeDifference % aMinute) / aSecond);
// Output the result
document.getElementById("timer").innerHTML = days + "d : " + hours + "h : "
+ minutes + "m : " + seconds + "s ";
// Message to show after the count down over
if (timeDifference < 0) {
clearInterval(countdown);
document.getElementById("timer").innerHTML = "DATE EXPIRED";
}
}, 1000);
</script>