I have done a javascript code and it works good. This script gets the difference between two dates. Now I want to write this script in php language, but it returns wrong values.
I want to achieve this via php. This is what I have done so far in PHP:
$NOW = strtotime("now");
$Time = 151048737944;
function dateDiff($date1, $date2)
{
    $diff = abs($date1 - $date2);
    if (floor($diff / 31536000000)) {
        echo floor($diff / 31536000000) . " year";
    } else if (floor($diff / 86400000)) {
        echo floor($diff / 2592000000) . " months";
    } else if (floor($diff / 86400000)) {
        echo floor($diff / 86400000) . " days";
    } else if (floor($diff / 3600000)) {
        echo floor($diff / 3600000) . " hours";
    } else if (floor($diff / 60000)) {
        echo floor($diff / 60000) . " minutes";
    } else {
        echo "now";
    }
}
dateDiff($NOW, $Time);
For 151048737944 it return: 4 year
 
     
    