Getting the Time difference in PHP
Feb.03, 2010 in
PHP
Gettting the time difference between to given dates/time
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("10-01-02 19:00:00","10-01-03 18:56:32");

Leave a Reply