Re: Subtraction of two units of time.
| From: | Peter Beckman | Date: | Thu, 06 Mar 2003 20:46:01 +0000 |
| Subject: | Re: Subtraction of two units of time. | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-26139@lists.php.net to get a copy of this message | ||
$foo = split(":",$time1);
$bar = split(":",$time2);
$time1 = mktime($foo[0],$foo[1],$foo[2],1,1,1980);
$time2 = mktime($bar[0],$bar[1],$bar[2],1,1,1980);
$total = $time1 - $time2;
That will give you the difference in seconds between the two.
I'll let you convert it to hh:mm:ss.
Peter
On Thu, 6 Mar 2003, David Rice wrote:
>
>
> I want to take away two times stored in the format "00:00:00" in a mysql
> database, i retrieve the times and take them away by using the following
>
> $total = $time1 - $time2 ;
>
> when i echo the total it is a whole number of the hours.. and does not take
> the minutes into account, anyone have an idea of how to get an exact answer
> to 2decimal places of the subtraction of the two times?
>
> cheers,
> dave
>
>
>
> _________________________________________________________________
> Chat online in real time with MSN Messenger
> http://messenger.msn.co.uk
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
---------------------------------------------------------------------------
Peter Beckman Internet Guy
beckman@purplecow.com http://www.purplecow.com/
---------------------------------------------------------------------------