List previous 12 months since current month

To get previous 12 months since current month you can use below code:

$month = date('n'); // current month
for ($m = 0; $m < 12; $m++) {
 echo date('F - Y', mktime(0,0,0,$month - $m,1)) . '<br />';
}

Result:
May - 2013
April - 2013
March - 2013
February - 2013
January - 2013
December - 2012
November - 2012
October - 2012
September - 2012
August - 2012
July - 2012
June - 2012
Tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *