Skip to content

Instantly share code, notes, and snippets.

@ivolivares
Created April 19, 2016 15:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivolivares/2a398909444517de732237462c6b19f4 to your computer and use it in GitHub Desktop.
Save ivolivares/2a398909444517de732237462c6b19f4 to your computer and use it in GitHub Desktop.
Time Conversion
var timeConversion = function(millisec) {
var seconds = (millisec / 1000).toFixed(1),
minutes = (millisec / (1000 * 60)).toFixed(1),
hours = (millisec / (1000 * 60 * 60)).toFixed(1),
days = (millisec / (1000 * 60 * 60 * 24)).toFixed(1);
if (seconds < 60) {
return seconds + " Sec";
} else if (minutes < 60) {
return minutes + " Min";
} else if (hours < 24) {
return hours + " Hrs";
} else {
return days + " Days"
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment