Skip to content

Instantly share code, notes, and snippets.

@anmonteiro
Created March 17, 2014 14:30
Show Gist options
  • Save anmonteiro/9600256 to your computer and use it in GitHub Desktop.
Save anmonteiro/9600256 to your computer and use it in GitHub Desktop.
Little function to get the remaining time until a target date - still WIP
var getCountdown = function(targetDate){
var left = targetDate.getTime() - new Date().getTime();
var seconds = + ((left / 1000) % 60) ;
var minutes = + ((left / (1000*60)) % 60);
var hours = + ((left / (1000*60*60)));
return hours.toFixed(0)+' h '+minutes.toFixed(0)+' min '+seconds.toFixed(0) + ' s';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment