-
-
Save jfsiii/627622 to your computer and use it in GitHub Desktop.
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
// converts milliseconds to '3:45' or if hours > 0, '2:01:23' | |
var getTimeFromMillis = function( ms ) | |
{ | |
var seconds = ':' + twoDigit( ~~( ( ms / 1000 ) % 60 ) ), | |
minutes = ~~( ( ms / ( 1000 * 60 ) ) % 60 ), | |
hours = ~~( ( ms / ( 1000 * 60 * 60 ) ) ); | |
function twoDigit( n ) { return n < 10 ? '0' + n : n; } | |
return hours > 0 ? hours + ':' + twoDigit( minutes ) + seconds : minutes + seconds; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment