Skip to content

Instantly share code, notes, and snippets.

@dawnerd
Last active September 24, 2015 05:57
Show Gist options
  • Save dawnerd/701335 to your computer and use it in GitHub Desktop.
Save dawnerd/701335 to your computer and use it in GitHub Desktop.
Shortest countdown function ever.
setInterval(function() {
console.log([s = [86400000, 3600000, 60000, 1000]][0].map(function(t) {
return ("0" + [(t===s[0] && (remaining = (future - ~~(+new Date()/1000))*1000)), left = ~~(remaining/t), remaining -= left*t][1]).slice(-2);
}).join(':'));
}, [1000, future = +new Date()/1000 + 100000][0]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment