Skip to content

Instantly share code, notes, and snippets.

@boogie666
Last active January 1, 2016 20:49
Show Gist options
  • Save boogie666/8199091 to your computer and use it in GitHub Desktop.
Save boogie666/8199091 to your computer and use it in GitHub Desktop.
Happy New Year
var finalCountDown = (function(){
var end = new Date('01/01/2014 00:00:00'),
timer,
second = 1000,
minute = second * 60,
hour = minute * 60,
day = hour * 24;
return function(textSetter){
timer = setInterval(function() {
var diff = end - new Date(),
hours = Math.floor((diff % day) / hour),
minutes = Math.floor((diff % hour) / minute),
seconds = Math.floor((diff % minute) / second);
if(diff <= 0){
clearTimeout(timer);
textSetter("Happy New Year!");
return;
}
textSetter(hours + ' hours ' + minutes +' minutes ' + seconds +' seconds remaning');
}, second);
};
}());
/*
finalCoundDown(function(text){
console.log(text);
});
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment