When I try to add a month to a date and it's the last day of the month, i get this weird behavior
$data = date("Y-m-d", $date); // $date is 1643583600and $data-> 2022-01-31
$duedate = new DateTime($data); // $duedate -> "2022-01-31 00:00:00.000000"
$duedate->modify('+1 month'); // $duedate -> "2022-03-03 00:00:00.000000"
$m = $duedate->format('m'); // $m = 03
However, the problem does not exist if:
- I want to add a month to 2022-02-28
- the starting date is not a month end