I'm trying to get an array of 12 months starting with current month, decrement and be like "Mar 2022".
This is my code:
$months = array();
$count = 0;
while ($count <= 11) {
$months[] = date('M Y', strtotime("-".$count." month"));
$count++;
}
But has some problems with months with fewer days.
For example: dd($months[0]) => "Mar 2022"
and dd($months[1]) => "Mar 2022"
had to be "Feb 2022".