$startDate = new DateTime("2016-06-01");
$endDate = new DateTime("2016-06-30");
$diff = date_diff($startDate,$endDate);
$differenceYear = $diff->format("%y");
$differenceMonth = $diff->format("%m");
$difference = $differenceYear*12 + $differenceMonth;
echo $difference;
Above code will output 0 as the result. But when I change those two dates to 2016-12-01 and 2016-12-31 the code gives 1 as the output. Why is that happening?
When I check this code online php editor it gives the right answer. But when I copied it to my local machine the answer shows wrong. Online editor has US/Pacific as the timezone. My pc has Asia/Kolkata timezone. Both has the same PHP version