Without using PHP 5.3’s date_diff function (I’m using PHP 5.2.17), is there a simple and accurate way to do this? I am thinking of something like the code below, but I don’t know how to account for leap years:
$days = ceil(abs( strtotime('2000-01-25') - strtotime('2010-02-20') ) / 86400);
$months = ???;
I’m trying to work out the number of months old a person is.
You may want to include the days somewhere too, depending on whether you mean whole months or not. Hope you get the idea though.