Can somebody please explain me the result of DateTime::diff() in the following example:
$start = DateTime::createFromFormat('Y/m/d', '2013/05/11');
$end = DateTime::createFromFormat('Y/m/d', '2015/03/08');
$diff = $start->diff($end);
var_dump($diff);
exit;
Result:
object(DateInterval)#19 (15) {
["y"]=>
int(1)
["m"]=>
int(9)
["d"]=>
int(25)
["h"]=>
int(0)
["i"]=>
int(0)
["s"]=>
int(0)
["weekday"]=>
int(0)
["weekday_behavior"]=>
int(0)
["first_last_day_of"]=>
int(0)
["invert"]=>
int(0)
["days"]=>
int(666)
["special_type"]=>
int(0)
["special_amount"]=>
int(0)
["have_weekday_relative"]=>
int(0)
["have_special_relative"]=>
int(0)
}
This is what I think is happened here: $diff->y is 1 because there is one full year between dates; $diff->m is 9 because there are 9 full months between dates (without 2013/05 and 2015/03).
I'd like to know how number 25 is calculated. I can'f figure out where this number comes from.
I'd expect here the difference between 2013/05/11 and 2013/05/31 + 2015/03/01 and 2015/03/08, so 20 + 7 = 27. Instead I got 25.