At 11:40 AM -0400 4/20/10, Floyd Resler wrote:
I need to get the difference in months between two dates. The dates could be as much as 60 months apart. Is there any easy way to do this either through PHP or MySQL? I know how I can do it through code but thought there might be a simple one or two line option.



$date1 = '2009-02-27';
$date2 = '2004-12-03';

$udate1 = strtotime($date1);
$udate2 = strtotime($date2);

$difference = $udate1 - $udate2;

$months_difference = floor($difference / 2678400);

echo("The difference is $months_difference months");


I this will work, but the question of what constitutes a month might come into play.



PHP General Mailing List (
To unsubscribe, visit:

Reply via email to