From the below code im getting the current year months from current month
<?php
$month = strtotime(date('Y').'-'.date('m').'-01');
$i=1; while($i <= 12){
$month_name = date('F', $month);
$nextmonth = date('m', $month);
$oneminus = strtotime('-1 month', $month);
$monthnumber = date('m', $oneminus);
$month = strtotime('+1 month', $month);
$getmonth = date('m',$month);
echo $month_name."<br/>";
$i++; }
Once December is done.I need to next year month how can i get that ?
for ex :
My expected result is :
September - 2015
October - 2015
November - 2015
December - 2015
January - 2016
February - 2016
March - 2016
April - 2016
May - 2016
June - 2016
July - 2016
August - 2016
For more details strtotime
$i=0;
while($i<12){
echo date("F - Y ",strtotime($i." months"));
echo "<br />";
$i++;
}
Check this
I think you need this one..
function showMonthYear($offset)
{
echo date("F - Y", strtotime("$offset months")).'<br />';
}
$months = array_map('showMonthYear', range(0, 12));
which will print result, just like you needs. Hope it will solve your problem.