php difference in date - month

<?php
$d1=date('2011-1-1');
$d2=date('2011-5-2');
echo "the date d1 =  ".$d1."<br>";
echo "the date d2  = ".$d2."<br>";
$date_diff=strtotime($d2)-strtotime($d1);
echo "date difference in months => ".floor(($date_diff)/2628000)." months <br>";
?>

No comments:

Other Articles

Enter your email address: