Php computing monthly spacing-php Tutorial

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.