Created
April 19, 2016 15:43
-
-
Save ivolivares/2a398909444517de732237462c6b19f4 to your computer and use it in GitHub Desktop.
Time Conversion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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