Difference between 2 time entries

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

 



Morning all,


I am looking to get the differnce in hours / minutes between 2 values.

Currently I have 2 time entries being retruned from mysql, one which is a
start time and
the other which is a finish time.

So

$start = '13:12:17';
$finish = '23:12:17';

How would one get the differnce between these 2 times??

I have looked at using the following but am not to sure....



function timeDiff($firstTime,$lastTime)
{

// convert to unix timestamps
$firstTime=strtotime($firstTime);
$lastTime=strtotime($lastTime);

// perform subtraction to get the difference (in seconds) between times
$timeDiff=$lastTime-$firstTime;

// return the difference
return $timeDiff;
}

//Usage :
echo timeDiff("$start","$finish");

Thanks

Chris

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux