<?php $d1 = new DateTime('2019-01'); $d2 = new DateTime('2019-04'); $interval = $d2->diff($d1); $counter = (int) $interval->format('%m'); do { echo $counter . PHP_EOL; echo $d1->format( 'Y-m-t' ) . PHP_EOL; $d1->modify('+1 months'); $counter--; } while ($counter >= 0);
You have javascript disabled. You will not be able to edit any code.