"CountDown Time New Year v1.0.1"
Bootstrap 4.1.1 Snippet by HIEUGB

1
2
3
4
5
6
7
8
9
10
<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>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
body {
background: #337ab7;
margin-top: 51px;
}
p, span {
text-align: center;
font-size: 60px;
margin-top: 0px;
color: #ffffff;
font-weight: 900;
}
#countdown {
text-shadow: 1px 1px 2px #000;
}
#to-day {
color: #A9A9A9;
text-shadow: 1px 1px 0 #FFF, -1px 2px 1px #000, 1px 2px 1px #000;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Related: See More


Questions / Comments: