Skip to content

Instantly share code, notes, and snippets.

@johnciacia
Created May 22, 2013 04:00
Show Gist options
  • Save johnciacia/5625163 to your computer and use it in GitHub Desktop.
Save johnciacia/5625163 to your computer and use it in GitHub Desktop.
Countdown Timer
setInterval(function() {
var s = new Date(),
e = new Date(2013, 9, 10, 0, 0, 0),
t = e.getTime() - s.getTime(),
x = t / 1000,
s = '0'+Math.floor(x % 60),
x = x / 60,
m = '0'+Math.floor(x % 60),
x = x / 60,
h = '0'+Math.floor(x % 24),
x = x / 24,
d = Math.floor(x),
time = [d, h.substr(-2), m.substr(-2), s.substr(-2)].join(':');
console.log(time);
}, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment