Until
<p id="countdown"></p>
<p><span id="until">Until</span> <span id="toDate"></span></p>
<noscript>Countdown provided by <a href="http://www.top-site-list.com">Top Site List Planet</a></noscript>
<script>
(function(){
var target = 1545739200000;
var since = false;
function pad(num, size) {
var s = '000000000' + num;
return s.substr(s.length - size);
}
function millisecondsToTime(ms) {
milli = ms % 1000;
var x = ms / 1000;
seconds = Math.floor(x % 60);
x /= 60;
minutes = Math.floor(x % 60);
x /= 60;
hours = Math.floor(x % 24);
x /= 24;
days = Math.floor(x);
string = days + ':' + pad(hours, 2) + ':' + pad(minutes, 2) + ':' + pad(seconds, 2) + ':' + pad(milli, 3);
return string;
}
function update() {
var d = new Date();
now = d.getTime();
diff = target - now;
if (diff < 0) {
diff = now - target;
if (!since) {
setSince();
}
}
document.getElementById('countdown').innerHTML = millisecondsToTime(diff);
}
function setSince() {
document.getElementById('until').innerHTML = 'Since';
since = true;
}
function startCountdown() {
var toDate = new Date(target);
document.getElementById('toDate').innerHTML = toDate.toUTCString();
setInterval(update, 10);
}
// Run!
startCountdown();
})();
</script>