seconds to hh:mm:ss format
Moderator: General Moderators
-
new2phpcode
- Forum Newbie
- Posts: 21
- Joined: Tue Oct 09, 2007 10:40 pm
seconds to hh:mm:ss format
is there a function that will convert seconds in hh:mm:ss format in php? 
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
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
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!
http://www.php.net/manual/en/ref.datetime.php#78025
Those comments are GOLD for newbies!
-
new2phpcode
- Forum Newbie
- Posts: 21
- Joined: Tue Oct 09, 2007 10:40 pm
-
new2phpcode
- Forum Newbie
- Posts: 21
- Joined: Tue Oct 09, 2007 10:40 pm