Formula for converting Seconds to hh:mm:ss
Formula for converting Seconds to hh:mm:ss
by Douglas Mitchell on 06/16/04 at 14:10:18
What is the formula for converting seconds to hh:mm:ss (I'll be using MDX)?
example: 132 seconds = 2 minutes and 12 seconds (132 seconds = 00:02:12).
Re: Formula for converting Seconds to hh:mm:ss
by Robert Fogt on 06/16/04 at 19:27:48
The formula I use on the site here is not really a formula, but the built in Date function of JavaScript.
Mostly a function would deal with dividing by 60. Something like:
[pre]
if (seconds >= 60)
{
minutes = (int) seconds / 60;
seconds -= (minutes * 60);
if (minutes >= 60)
{
hours = (int) minutes / 60;
minutes -= (hours * 60);
}
}
[/pre]
Thats off the top of my head. There is bound to be an easier method.