"Countdown Timer"
Bootstrap 4.1.1 Snippet by trinhquan

<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <!------ Include the above in your HEAD tag ----------> <div class="container"> <!--<span id="day"></span>--> <p id="countdown"></p> <p id="to-day"></p> </div>
body { background: #337ab7; margin-top: 51px; } p, span { text-align: center; font-size: 60px; margin-top: 0px; color: #ffffff; font-weight: 900; } /*#countdown {*/ /* text-align: right;*/ /* margin-right: 265px;*/ /*}*/ /*#day {*/ /* position: absolute;*/ /* left: 468px;*/ /* color: #b59494;*/ /*}*/
var d = new Date(); var year = d.getFullYear()+1; // Set the date we're counting down to var countDownDate = new Date("Jan 1, "+year+" 00:00:00").getTime(); // Update the count down every 1 second var x = setInterval(function() { // Get today's date and time var now = new Date().getTime(); // Find the distance between now and 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); if(hours < 10) { hours = '0'+hours; } if(minutes < 10) { minutes = '0'+minutes; } if(seconds < 10) { seconds = '0'+seconds; } // Output the result in an element with id="demo" // document.getElementById("day").innerHTML = days + "DAY"; document.getElementById("countdown").innerHTML = d + ' - ' + hours + " : " + minutes + " : " + seconds; document.getElementById("to-day").innerHTML = days + 'days will be the day 01/01/' + year; // If the count down is over, write some text if (distance < 0) { clearInterval(x); document.getElementById("countdown").innerHTML = "HAPPY NEW YEAR"; document.getElementById("to-day").innerHTML = year; } }, 1000);

Related: See More


Questions / Comments: