PHP returns nearly 7 days this month last month date

Source: Internet
Author: User

1<?PHP2 /**3 * Return nearly 7 days, month, month data4 * Regardless of the day (display background data dedicated)5  */6 functionWeekmonthlastmonth ($search _date= ' Week ') {7 8     Switch($search _date)9     {Ten          Case' Week '://nearly 7 days One             $start _date=Date("Y-m-d",Strtotime("-7 Days"))); A             $end _date=Date("Y-m-d",Strtotime("-1 Days"))); -              Break; -          Case' Month '://this month the             $start _date=Date("y-m-01",Strtotime("-1 Days"))); -             $end _date=Date("Y-m-d",Strtotime("-1 Days"))); -              Break; -          Case' Last_month '://last month +             $search _time=Strtotime("-1 month")); -             $start _date=Date("y-m-01",$search _time); +             $end _date=Date(' y-m-d ',Strtotime("$start _date+1 month-1 Day ")); A              Break; at     } -     return Array($start _date,$end _date); - } -  - Echo Print_r(Weekmonthlastmonth (' Week '),true); - Echo Print_r(Weekmonthlastmonth (' month '),true); in Echo Print_r(Weekmonthlastmonth (' Last_month '),true);

PHP returns nearly 7 days this month last month date

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.