Created
March 9, 2014 04:14
-
-
Save yyoshiki41/9442845 to your computer and use it in GitHub Desktop.
function countdown();
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function countDown() { | |
var startDateTime = new Date(); | |
var endDateTime = new Date("March 9,2015 18:00:00"); | |
var left = endDateTime - startDateTime; | |
var a_day = 24 * 60 * 60 * 1000; | |
var h = Math.floor((left % a_day) / (60 * 60 * 1000)), | |
m = Math.floor((left % a_day) / (60 * 1000)) % 60, | |
s = Math.floor((left % a_day) / 1000) % 60 % 60; | |
document.getElementById("#timer")[0].innerHTML = addZero(h) + ':' + addZero(m) + ':' + addZero(s); | |
setTimeout('countDown()', 1000); | |
} | |
function addZero(num) { | |
num = '00' + num; | |
str = num.substring( num.length - 2, num.length ); | |
return str ; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment