Skip to content

Instantly share code, notes, and snippets.

@seriusokhatsky
Last active September 9, 2016 14:25
Show Gist options
  • Save seriusokhatsky/5e3c9bf19ff10470c222 to your computer and use it in GitHub Desktop.
Save seriusokhatsky/5e3c9bf19ff10470c222 to your computer and use it in GitHub Desktop.
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