Last active
September 9, 2016 14:25
-
-
Save seriusokhatsky/5e3c9bf19ff10470c222 to your computer and use it in GitHub Desktop.
This file contains 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 fridayTime = function() { | |
var now = new Date(), | |
day = now.getDay(), | |
date = now.getDate(), | |
fridayDate = date + (5 - day), | |
friday = new Date(2016, now.getMonth(), fridayDate), | |
timeDiff = Math.abs(friday.getTime() - now.getTime()), | |
msToTime = function(s) { | |
var ms = s % 1000; | |
s = (s - ms) / 1000; | |
var secs = s % 60; | |
s = (s - secs) / 60; | |
var mins = s % 60; | |
var hrs = (s - mins) / 60; | |
return hrs + ':' + mins + ':' + secs; | |
}; | |
console.log('Friday will come in ' + msToTime(timeDiff) + ' hours :)'); | |
}; | |
setInterval(fridayTime, 1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment