Re: calculate 2 times

From: Date: Wed, 23 Jan 2002 12:50:39 +0000
Subject: Re: calculate 2 times
Groups: php.general 
Request: Send a blank email to php-general+get-81671@lists.php.net to get a copy of this message
You can use mktime() to calculate the unix timestamp of the date. Once you have the difference in seconds you can easily display the time taken. <? $time = $stop - $start; $hours = (int)($time / 3600); $time -= ($hours * 3600); $mins = (int)($time / 60); $time -= ($mins * 60); if ($hours) { $show = $hours . ":"; } if ($mins) { $show .= $mins . ":"; } echo $show . $time; ?> On Wed, 23 Jan 2002 12:22:57 -0000, Martin E. Koss wrote: > >Hi. I've been trying to get the difference between a $StartTime and $EndTime >for the past couple of hours... failing miserably.. and I have rtfm! >Obviously I'm missing something. > >The format of the data stored in the database is: >hh:mm:ss (eg: 17:22:17) 24hr time. > >The $EndTime may only be a few seconds or may be several hours different >from the $StartTime. I need to display the difference in the same format >(hh:mm:ss). > >Can someone please help? > >Martin E. Koss >E: mek@mek.co.uk > > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net >For additional commands, e-mail: php-general-help@lists.php.net >To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.general (#81671) next »