I'm using a code to find how many days have passed since the new year (January 1). I use this code:
$newyear = new DateTime("2017-01-01"); // January 1, 2017.
$today = new DateTime(); // March 6, 2017.
$difference = $newyear->diff($today);
Now, if I use this code, it shows the right number of days,
echo $difference->format("%a days"); // 64 days
but when I use a different format, it goes wrong.
echo $difference->format("%m months %d days"); // 2months 2 days.
I assume this is due to PHP counting February as 31 days long, so technically it is 31 + 31 + 2 days. I want it to count February as 28 or 29 days long, depending on the leap year condition. I guess there must be something in php.ini related to this. What and where to change or is there any hack?