Convert Millisecond To Second Javascript Code Example


Example: convert milliseconds to minutes and seconds javascript


const millisToMinutesAndSeconds = (millis) => {
var minutes = Math.floor(millis / 60000);
var seconds = ((millis % 60000) / 1000).toFixed(0);
//ES6 interpolated literals/template literals
//If seconds is less than 10 put a zero in front.
return `${minutes}:${(seconds < 10 ? "0" : "")}${seconds}`;
}

Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable