Re: Subtraction of two units of time.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



$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/
---------------------------------------------------------------------------

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux