Re: Seconds to minutes

From: Date: Wed, 20 Nov 2002 02:41:08 +0000
Subject: Re: Seconds to minutes
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-125182@lists.php.net to get a copy of this message
Ahhh - that works a treat! First time I've seen the floor command in action. Thanks Jonathon. Still more lines of code than I'd like, but obviously its not that easy to do! Best Regards Bob Irwin Server Admin & Web Programmer Planet Netcom ----- Original Message ----- From: "Jonathan Sharp" <js-lists@sharpmedia.net> To: <holmes072000@charter.net> Cc: "'Matt'" <mschroebel@epooch.com>; "'Bob Irwin'" <bob@staff.pnc.com.au>; <php-general@lists.php.net> Sent: Wednesday, November 20, 2002 12:41 PM Subject: Re: [PHP] Seconds to minutes > i'll just throw my code in here while we're at it... > > $seconds = 3600*5 + (60 * 10) + 45; > > $hours = floor( $seconds / 3600 ); > $mins = floor( ($seconds % 3600) / 60 ); > $seconds = floor( ($seconds % 60) ); > > echo "Hours: $hours\nMins: $mins\nSeconds: $seconds\n"; > > -js > > > John W. Holmes wrote: > >>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... > > > > > > > > > > > Scanned by PeNiCillin http://safe-t-net.pnc.com.au/ > Scanned by PeNiCillin http://safe-t-net.pnc.com.au/

« previous php.general (#125182) next »