There is a problem with time calculation... list the last 6 months & lt ;? $ Arrarray (); $ nowddate (& quot; Ym & quot;); $ arr [] date (& quot; Ym & quot;, strtotime (& quot; -6 month & quot;); $ arr [] date (& quot; Ym & quot;, strtotime time calculation is faulty... list the last 6 months
$ Arr = array ();
$ Nowd = date ("Ym ");
$ Arr [] = date ("Ym", strtotime ("-6 month "));
$ Arr [] = date ("Ym", strtotime ("-5 month "));
$ Arr [] = date ("Ym", strtotime ("-4 month "));
$ Arr [] = date ("Ym", strtotime ("-3 month "));
$ Arr [] = date ("Ym", strtotime ("-2 month "));
$ Arr [] = date ("Ym", strtotime ("-1 month "));
$ Arr [] = date ("Ym ");
$ Arr [] = date ("Ym", strtotime ("+ 1 month "));
$ Arr [] = date ("Ym", strtotime ("+ 2 month "));
$ Arr [] = date ("Ym", strtotime ("+ 3 month "));
$ Arr [] = date ("Ym", strtotime ("+ 4 month "));
$ Arr [] = date ("Ym", strtotime ("+ 5 month "));
$ Arr [] = date ("Ym", strtotime ("+ 6 month "));
For ($ I = 0; $ I Echo "". $ arr [$ I]. ",";
If ($ I % 3 = 0)
Echo'
';
}
?>
Two 201203 numbers are printed in the middle.
201204 is gone...
It is normal only when the day is 2012-31. please analyze it...
During the test, set the date to 3.31.
------ Solution --------------------
Use your code
$ Nowd = date ("Y-m-1 ");
Shape like
$ Arr [] = date ("Ym", strtotime ("-6 month "));
All are changed to shapes like
$ Arr [] = date ("Ym", strtotime ("-6 month $ nowd "));
You can.