Is there any function equivalent to DateTime::diff() in PHP 5.2?
My local server is PHP 5.3 and using DateTime::diff(). then I found that my live site uses PHP 5.2 a
I use this, seems to work alright - obviously you can add a second parameter to make it more flexible:
function GetDateDiffFromNow($originalDate)
{
$unixOriginalDate = strtotime($originalDate);
$unixNowDate = strtotime('now');
$difference = $unixNowDate - $unixOriginalDate ;
$days = (int)($difference / 86400);
$hours = (int)($difference / 3600);
$minutes = (int)($difference / 60);
$seconds = $difference;
// now do what you want with this now and return ...
}