# This isnt working right

**URL:** <https://forum.kirupa.com/t/this-isnt-working-right/186540>\
**Category:** Uncategorized\
**Created:** [April 22, 2006, 3:41am UTC](https://forum.kirupa.com/t/this-isnt-working-right/186540 "2006-04-22T03:41:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![zicemaster](https://avatars.discourse-cdn.com/v4/letter/z/b77776/32.png) [@zicemaster](https://forum.kirupa.com/u/zicemaster)\
**Post date:** [April 22, 2006, 3:41am UTC](https://forum.kirupa.com/t/this-isnt-working-right/186540/1 "2006-04-22T03:41:38Z")

</div>

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!

```auto

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

```

---

<div class="post-metadata">

**Author:** ![nathan99](https://avatars.discourse-cdn.com/v4/letter/n/96bed5/32.png) [@nathan99](https://forum.kirupa.com/u/nathan99)\
**Post date:** [April 22, 2006, 4:33am UTC](https://forum.kirupa.com/t/this-isnt-working-right/186540/2 "2006-04-22T04:33:05Z")

</div>

```auto
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??

---

<div class="post-metadata">

**Author:** ![TheCanadian](https://avatars.discourse-cdn.com/v4/letter/t/67e7ee/32.png) [@TheCanadian](https://forum.kirupa.com/u/TheCanadian)\
**Post date:** [April 22, 2006, 5:30am UTC](https://forum.kirupa.com/t/this-isnt-working-right/186540/3 "2006-04-22T05:30:33Z")

</div>

Or the more mathematical approach:

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

```

:tie:

---

<div class="post-metadata">

**Author:** ![zicemaster](https://avatars.discourse-cdn.com/v4/letter/z/b77776/32.png) [@zicemaster](https://forum.kirupa.com/u/zicemaster)\
**Post date:** [April 22, 2006, 9:37pm UTC](https://forum.kirupa.com/t/this-isnt-working-right/186540/4 "2006-04-22T21:37:40Z")

</div>

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.
