"Countdown Timer"
Bootstrap 4.1.1 Snippet by trinhquan

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">
<!--<span id="day"></span>-->
<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
20
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;*/
/*}*/
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();
// 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;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Related: See More


Questions / Comments: