<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">
<p id="countdown"></p>
<p id="to-day"></p>
</div>
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();
var countDownDate = new Date(+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("countdown").innerHTML = d + ' - ' + hours + ' : ' + minutes + ' : ' + seconds;
document.getElementById("countdown").innerHTML = ' Còn ' + days + ' Ngày ' + hours + ' : '
+ minutes + ' : ' + seconds;
//document.getElementById("to-day").innerHTML = days + ' days will be the day ' + year;
document.getElementById("to-day").innerHTML = ' sẽ đón Tết năm ' + 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);