Skip to content

Instantly share code, notes, and snippets.

@wemakeweb
Created March 11, 2012 18:57
Show Gist options
  • Save wemakeweb/2017679 to your computer and use it in GitHub Desktop.
Save wemakeweb/2017679 to your computer and use it in GitHub Desktop.
var humanize = function(ms) {
var sec = 1000
, min = 60 * 1000
, hour = 60 * min;
if (ms >= hour) return (ms / hour).toFixed(1) + 'h';
if (ms >= min) return (ms / min).toFixed(1) + 'm';
if (ms >= sec) return (ms / sec | 0) + 's';
return ms + 'ms';
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment