Last active
January 1, 2016 20:49
-
-
Save boogie666/8199091 to your computer and use it in GitHub Desktop.
Happy New Year
This file contains hidden or 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
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