Skip to content

Instantly share code, notes, and snippets.

@jczaplew
Created July 31, 2013 17:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jczaplew/6124012 to your computer and use it in GitHub Desktop.
Save jczaplew/6124012 to your computer and use it in GitHub Desktop.
<!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