Example:-1
When current month is march.
$month[0]=date('m');
for ($i = 1; $i<6; $i++) {
$month[$i]=date('m',strtotime(date('Y-m-01')." -$i month"));
}
print_r($month);
die();
Output
Array
(
[0] => 03
[1] => 02
[2] => 01
[3] => 12
[4] => 11
[5] => 10
)
Copyright ©2022 coderraj.com. All Rights Reserved.