Php calculates the monthly spacing. for example, if this month is in February, it is calculated from the previous month to February to the next four months (considering the cross-year plan ), the timestamp of every month, that is, 2011.9-2013.1 scores are not much, and the post is timely. thank you! ------ Solution -------------------- WHERE & nbsp; date & nbsp; & lt; & nbsp; php calculates the monthly spacing
For example, this month is July
Calculate the timestamp of each month from the previous month to the next four months (considering the cross-year period ).
That is, 2011.9-2013.1
No scores are given, and the post is timely. thank you!
------ Solution --------------------
WHERE date <". strtotime ('+ 4 month')." AND date> ". strtotime ('-12 month ')."
------ Solution --------------------
$ T = date ('Y-m-01 '); // The current time cannot be used directly, otherwise there will be issues at the end of the month
For ($ I =-12; $ I <= 4; $ I ++ ){
Echo date ('Y. M', strtotime ("$ I month $ t"), PHP_EOL;
}
2011.09
2011.10
2011.11
2011.12
2012.01
2012.02
2012.03
2012.04
2012.05
2012.06
2012.07
2012.08
2012.09
2012.10
2012.11
2012.12
2013.01