Created
February 1, 2017 18:12
-
-
Save sean-codes/2248a0f76e3287cccd6b8a3a61141ba5 to your computer and use it in GitHub Desktop.
Convert Milliseconds to a HH:MM:SS string
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
var milliseconds = 101000; | |
console.log(convertMillToString(milliseconds)); | |
function convertMillToString(milliseconds){ | |
var totalSeconds = milliseconds/1000; | |
var totalMinutes = Math.floor(totalSeconds/60); | |
//Return Values | |
var hours = Math.floor(totalMinutes/60); | |
var minutes = totalMinutes - (hours*60); | |
var seconds = totalSeconds - (totalMinutes*60); | |
return hours + ':' + minutes + ':' + seconds; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment