Created
September 2, 2013 22:48
-
-
Save mikeerickson/6417955 to your computer and use it in GitHub Desktop.
Milliseconds to TimeFormat (hh:mm:ss.tt)
This file contains hidden or 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
function msToTime(s) { | |
function addZ(n) { | |
return (n<10? '0':'') + n; | |
} | |
var ms = s % 1000; | |
s = (s - ms) / 1000; | |
var secs = s % 60; | |
s = (s - secs) / 60; | |
var mins = s % 60; | |
var hrs = (s - mins) / 60; | |
return addZ(hrs) + ':' + addZ(mins) + ':' + addZ(secs) + '.' + ms; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment