How to get the next 12 months from this month?
How to get the next 12 months from this month?
What I'm using now is:
PHP Code
for ($i =1; $i <=12; $i + +) { $nextdate = date ("Y-m", Strtotime ("+ $i Month")); Echo ''. $nextdate;}
Seems to be no problem, can print but found that March is repeated, I do not know why.
2009-11
2009-12
2010-01
2010-03
2010-03
2010-04
2010-05
2010-06
2010-07
2010-08
2010-09
2010-10
------Solution--------------------
Because your month is 28 days in 30 days, so it's not right to wait until February.
------Solution--------------------
PHP Code
The parameter represents a lot of months, you can also modify the Start function c ($num =) { $temp = array () for the specified date; $nowtime = strtotime (Date (' Y-m ', Time ()). '-1 '); while ($num >0) { $num--; $nowtime = Strtotime (' +1 month ', $nowtime); $temp [] = Date (' y-m ', $nowtime); } Unset ($num, $nowtime); return $temp;} Print_r (c ());