Re: Script to convert # of seconds to HH:mm
| From: | Phillip Bow | Date: | Mon, 19 Mar 2001 22:42:59 +0000 |
| Subject: | Re: Script to convert # of seconds to HH:mm | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-44639@lists.php.net to get a copy of this message | ||
function philtime($time){
$hours = (int) ($time / 3600);
$min = (int) (($time % 3600) / 60 );
return ("$hours:$min");
}
Should be 3600 since:
60sec = 1min
60min = 1hour
60 * 60 = 3600sec/hour
--
phill
> How about something like this:
>
> $secs = number of seconds;
> $hours = intval($secs/360);
> $minutes = intval(($secs-$hours*360)/60)
> $seconds = $secs - $hours*360 - $minutes * 60;
>
> Hope this helps.
>
> Michael Ridinger