I want to convert seconds into minutes.
For example 61 seconds should be displayed like 1:01 (not 1:1)
I tried with parseInt(sec / 60)
: sec % 60
.
If sec=61
it is showing like 1:1
.
I have data from music API that gives me music duration in seconds and I have to convert them into minutes. I tried
{parseInt(data.duration / 60 )} : {data.duration % 60}
sometimes it is giving me 3:35, 3:24
and 3:1
. I have to add 0 before 1 as well. How can I do it
I also tried with
{parseInt(data.duration / 60 )} : {parseFloat(data.duration % 60).toFixed(2)}
it is showing 1:1.00
I want to display it like 1:01
.
Thank you for your help in advance.