1function msToTime(duration) {
2 var milliseconds = parseInt((duration % 1000) / 100),
3 seconds = Math.floor((duration / 1000) % 60),
4 minutes = Math.floor((duration / (1000 * 60)) % 60),
5 hours = Math.floor((duration / (1000 * 60 * 60)) % 24);
6
7 hours = (hours < 10) ? "0" + hours : hours;
8 minutes = (minutes < 10) ? "0" + minutes : minutes;
9 seconds = (seconds < 10) ? "0" + seconds : seconds;
10
11 return hours + ":" + minutes + ":" + seconds + "." + milliseconds;
12}
13console.log(msToTime(300000))