Page 1 of 1
seconds to hh:mm:ss format
Posted: Wed Oct 10, 2007 12:42 am
by new2phpcode
is there a function that will convert seconds in hh:mm:ss format in php?

Posted: Wed Oct 10, 2007 2:28 am
by volka
gmdate() might suffice.
Code: Select all
<?php
$seconds = 78432;
echo gmdate('H:i:s', $seconds), "\n";
echo gmdate('d H:i:s', $seconds), "\n\n";
$seconds = 78432 + 9876;
echo gmdate('H:i:s', $seconds), "\n";
echo gmdate('d H:i:s', $seconds), "\n\n";
?>
21:47:12
01 21:47:12
00:31:48
02 00:31:48
Posted: Wed Oct 10, 2007 3:16 am
by Kieran Huggins
check out the top comment in the manual page for the datetime functions:
http://www.php.net/manual/en/ref.datetime.php#78025
Those comments are GOLD for newbies!
Posted: Wed Oct 10, 2007 5:03 am
by new2phpcode
actually what i have done previously is correct using gmdate, but i just need the hh:mm:ss, for example i have 7098640.375 secs. the results should be something like 2019:10:07, actually i have done it manually..... well maybe in php there is, i hope so...

thanks for the reply...

.
Posted: Wed Oct 10, 2007 5:07 am
by new2phpcode
i guess, ill just convert the value in hours round it off, then use explode for the minutes and seconds...
