milliseconds of seconds in javascript code example
Example 1: convert milliseconds to minutes and seconds javascript
const millisToMinutesAndSeconds = (millis) => {
var minutes = Math.floor(millis / 60000);
var seconds = ((millis % 60000) / 1000).toFixed(0);
return `${minutes}:${(seconds < 10 ? "0" : "")}${seconds}`;
}
Example 2: convert milliseconds to seconds JS
function millisToMinutesAndSeconds(millis) {
var minutes = Math.floor(millis / 60000);
var seconds = ((millis % 60000) / 1000).toFixed(0);
return minutes + ":" + (seconds < 10 ? '0' : '') + seconds;
}
millisToMinutesAndSeconds(298999);
millisToMinutesAndSeconds(60999);