1// Set the date we're counting down to
2var start_at = new Date('2020-06-29 12:00:00');
3
4// Update the count down every 1 second
5var x = setInterval(function() {
6
7 // Get todays date and time
8 var now = new Date();
9
10 // Find the distance between now an the count down date
11 var distance = now - start_at;
12
13
14 // Time calculations for days, hours, minutes and seconds
15 var days = Math.floor(distance / (1000 * 60 * 60 * 24));
16 var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
17 var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
18 var seconds = Math.floor((distance % (1000 * 60)) / 1000);
19
20 // Output the result in an element with id="demo"
21 document.getElementById("demo").value = hours + "h "
22 + minutes + "m " + seconds + "s ";
23}, 1000);