Created
June 21, 2016 10:03
-
-
Save StipJey/f8fe63fa167b90cd59df8832f98a9cf8 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
var timeFormat = (function (){ | |
function num(val){ | |
val = Math.floor(val); | |
return val < 10 ? '0' + val : val; | |
} | |
return function (ms/**number*/){ | |
var sec = ms / 1000 | |
, hours = sec / 3600 % 24 | |
, minutes = sec / 60 % 60 | |
, seconds = sec % 60 | |
; | |
return num(hours) + ":" + num(minutes) + ":" + num(seconds); | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment