I need to get the last 13 months starting from the current month but when I try the code below. It gets every month but 022017. Any suggestions on why?
for ($i = 13; $i > 0; $i--) {
$dates->addDate(Carbon::now()->subMonth($i)->format('mY'));
}
results:
0 => "082016"
1 => "092016"
2 => "102016"
3 => "112016"
4 => "122016"
5 => "012017"
6 => "032017"
7 => "042017"
8 => "052017"
9 => "062017"
10 => "072017"
11 => "082017"