How come each time I call the
var track_length = $(".audio-player")[counter].duration;
it returns me this
351.234
How can I convert it to this type ofr Format minutes/seconds. 3:51 seconds ?(I am not sure if I am correct with my estimation of the time)
Do you mean you want to convert it to min and secs, if yes then:
function readableDuration(seconds) {
sec = Math.floor( seconds );
min = Math.floor( sec / 60 );
min = min >= 10 ? min : '0' + min;
sec = Math.floor( sec % 60 );
sec = sec >= 10 ? sec : '0' + sec;
return min + ':' + sec;
}
console.log( readableDuration(351.234) ); // 05:51
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With