Skip to content

Instantly share code, notes, and snippets.

@joshrhoades
Created January 27, 2014 21:30
Show Gist options
  • Save joshrhoades/8657740 to your computer and use it in GitHub Desktop.
Save joshrhoades/8657740 to your computer and use it in GitHub Desktop.
Quick function to format passed in seconds and determine the weeks, days, hours, minutes, and seconds in that time. Returns an object of the values.
var _formatCount = function(sec) {
return {
w: Math.floor(sec / 86400 / 7),//weeks
d: Math.floor(sec / 86400 % 7),//days
h: Math.floor(sec / 3600 % 24),//hours
m: Math.floor(sec % 3600 / 60),//minutes
s: Math.floor(sec % 3600 % 60)//seconds
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment