This isnt working right

I found some code and altered it a little… But it never worked correctly in the first place.

I’m trying to convert seconds into minutes. I need to find a way to insert a zero when seconds are under 10?

But it still acts weird after ten seconds… LOL!


function getTime(seconds) {
    part = String(seconds/60);
    part2 = part.split(".");
    time = part2[0]+":"+(part2[1]*6);
    return time.substring(0, 4);
}

function getTime(seconds) {
    part = String(seconds/60);
    part = part<10 ? "0"+part : part
    part2 = part.split(".");
    time = part2[0]+":"+(part2[1]*6);
    return time.substring(0, 4);
}

like that??

Or the more mathematical approach:

function getTime(seconds:Number):String {
 var sec:Number = seconds % 60;
 return (seconds - sec) / 60 + ":" + (sec < 10 ? "0" + sec : sec);
}

:tie:

Ohh, thanks a ton. I got it working!

Btw… Canadian, I wasn’t actually getting the time… Although my function was named like that.

I think I kinda confused ya. I was actually inputting the seconds from a mp3 player and converting it into a normal readable output.