Instead of dividing, use modulus to get the exact number of remaining seconds, and then determine the minutes from that.
Here is some code that I've quickly adapted from another language I use, to take the total minutes, and convert it to "hours:minutes" display.
$totalmins = 193;
$showmins = $totalmins%60;
$showhrs = ($totalmins-$showmins)/60;
echo $showhrs.":".$showmins;
I haven't tested this, but it might give you a start. The same concept would apply to converting seconds to minutes...
Peter
At 12:16 PM 11/20/2002 +1100, 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? Best Regards Bob Irwin Server Admin & Web Programmer Planet Netcom ----- Original Message ----- From: "John W. Holmes" <[EMAIL PROTECTED]> To: "'Matt'" <[EMAIL PROTECTED]>; "'Bob Irwin'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Wednesday, November 20, 2002 12:09 PM Subject: RE: [PHP] Seconds to minutes > > You can do something like this: > > <?php > > $seconds = 265; > > $time = date('i s',$seconds); > > $minSecs = explode(' ',$time); > > echo "{$minSecs[0]} minutes and {$minSecs[1]} seconds<br>\n"; > > ?> > > That doesn't work for anything over 3599 seconds, though... > > ---John Holmes... > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > Scanned by PeNiCillin http://safe-t-net.pnc.com.au/ > > Scanned by PeNiCillin http://safe-t-net.pnc.com.au/ > Scanned by PeNiCillin http://safe-t-net.pnc.com.au/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
- - - - - - - - - - - - - - - - - - - - - Fourth Realm Solutions [EMAIL PROTECTED] http://www.fourthrealm.com Tel: 519-739-1652 - - - - - - - - - - - - - - - - - - - - - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php