Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Convert Milliseconds to a HH:MM:SS string
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