On Wed, 20 Nov 2002, Bob Irwin wrote:
> Its seems far more reliable than what I am using (dividing by 60 for
> minutes, 3600 for hours and doing rounding, exploding if its not a round
> number etc).
>
> Its only for measuring short times, so Matt's suggestion should work ok.
> Ideally though, because it will crop up from time to time, it'd be the go to
> do it right the first time.
>
> Anyone else know of a better way?
How about something like this, given $seconds containing the number of
seconds?
$secs = $seconds;
$hours = $secs / 3600;
$secs %= 3600;
$mins = $secs / 60;
$mins %= 60;
$out = sprintf ("%d hour%s, %d minute%s, %d second%s",
$hours, ($hours == 1 ? '' : 's'),
$mins, ($mins == 1 ? '' : 's'),
$secs, ($secs == 1 ? '' : 's'));
--
Morgan Hughes
C programmer and highly caffeinated mammal.
[EMAIL PROTECTED]
ICQ: 79293356
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php