. Advertisement .
..3..
. Advertisement .
..4..
I would love to convert milliseconds to hours minutes seconds javascript but I don’t know if what is the best solution yet. Can you share with me more about the related knowledge?
Here is our case study:function msToTime(duration) {
var milliseconds = parseInt((duration % 1000) / 100),
seconds = Math.floor((duration / 1000) % 60),
minutes = Math.floor((duration / (1000 * 60)) % 60),
hours = Math.floor((duration / (1000 * 60 * 60)) % 24);
hours = (hours < 10) ? "0" + hours : hours;
minutes = (minutes < 10) ? "0" + minutes : minutes;
seconds = (seconds < 10) ? "0" + seconds : seconds;
return hours + ":" + minutes + ":" + seconds + "." + milliseconds;
}
console.log(msToTime(300000))
Have you ever tried this solution
I trust this is what you’re looking for?