> is there a way to take a number (specifically the
> milliseconds that a sound has been playing) and convert
> into minute:second format? any help?
Sure thing. First, you need to bear in mind that mm:hh
format is a
string, not a number, so whatever your usage is going to be
-- presumably a
dynamic text field display, but I'm only guessing -- it needs
compatible with strings.
Second, you simply need to perform a bit of math. Let's say
the number 87,540. That's 87,540 milliseconds, or 1 minute
and 27 seconds
(and 540 milliseconds, which we can probably just toss). Now,
how do we get
from the one to the other?
87540 / 1000 gives us seconds ... here, 87.54. Divide that
number by 60
and you have minutes.
To get seconds -- well, you already did that -- but in time
applications, seconds need to start over again at 60, so you
can use the
modulus operator, %, to do that for you.
If you want a leading zero, you may want to use an if()
check if that value is less than 10.