Created
July 31, 2013 17:12
-
-
Save jczaplew/6124012 to your computer and use it in GitHub Desktop.
Alternate of http://bl.ocks.org/svmatthews/6123346
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
<!DOCTYPE html> | |
<head> | |
<style> | |
body { | |
text-align:center; | |
} | |
#clock { | |
font-family:arial; | |
font-size:2em; | |
font-weight:bold; | |
color:#555; | |
} | |
</style> | |
</head> | |
<body> | |
<p id="clock"></p> | |
<script> | |
(function() { | |
var end = new Date('08/19/2013 10:1 AM'), | |
sec = 1000, | |
min = sec * 60, | |
hour = min * 60, | |
day = hour * 24, | |
timer; | |
timer = setInterval(function () { | |
var now = new Date(), | |
between = end - now; | |
var days = Math.floor(between / day), | |
hours = Math.floor((between % day) / hour), | |
minutes = Math.floor((between % hour) / min), | |
seconds = Math.floor((between % min) / sec); | |
var dayString = 'days ', | |
hourString = 'hrs ', | |
minString = 'mins ', | |
secString = 'secs '; | |
if (days == 1) { | |
dayString = 'day '; | |
}; | |
if (hours == 1) { | |
hourString = 'hr '; | |
}; | |
if (minutes == 1) { | |
minString = 'min '; | |
}; | |
if (seconds == 1) { | |
secString = 'sec '; | |
}; | |
var clock = days + dayString + hours + hourString + minutes + minString + seconds + secString; | |
document.getElementById("clock").innerHTML = clock; | |
}, 1000); | |
})(); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment