1function millisToMinutesAndSeconds(millis) {
2 var minutes = Math.floor(millis / 60000);
3 var seconds = ((millis % 60000) / 1000).toFixed(0);
4 return minutes + ":" + (seconds < 10 ? '0' : '') + seconds;
5}
6
7millisToMinutesAndSeconds(298999); // "4:59"
8millisToMinutesAndSeconds(60999); // "1:01"
9
1const millisToMinutesAndSeconds = (millis) => {
2 var minutes = Math.floor(millis / 60000);
3 var seconds = ((millis % 60000) / 1000).toFixed(0);
4 //ES6 interpolated literals/template literals
5 //If seconds is less than 10 put a zero in front.
6 return `${minutes}:${(seconds < 10 ? "0" : "")}${seconds}`;
7}
8