Get the code for this week, last week, this month, last month, this quarter date with PHP

Source: Internet
Author: User

1 Echo Date("Ymd",Strtotime("Now")), "\ n";2 Echo Date("Ymd",Strtotime("-1 week Monday")), "\ n";3 Echo Date("Ymd",Strtotime("-1 week Sunday")), "\ n";4 Echo Date("Ymd",Strtotime("+0 Week Monday"), "\ n";5 Echo Date("Ymd",Strtotime("+0 Week Sunday"), "\ n";6  7  8 //date (' n ') months9 //date ("W") Week of the weekTen //date ("T") days of the month One   A Echo' <br> last week:<br> '; - Echo Date("Y-m-d h:i:s",Mktime(0, 0, 0,Date("M"),Date("D")-Date("W") +1-7,Date("Y")), "\ n"; - Echo Date("Y-m-d h:i:s",Mktime(23,59,59,Date("M"),Date("D")-Date("W") +7-7,Date("Y")), "\ n"; the Echo' <br> this week:<br> '; - Echo Date("Y-m-d h:i:s",Mktime(0, 0, 0,Date("M"),Date("D")-Date("W") +1,Date("Y")), "\ n"; - Echo Date("Y-m-d h:i:s",Mktime(23,59,59,Date("M"),Date("D")-Date("W") +7,Date("Y")), "\ n"; -   + Echo' <br> last month:<br> '; - Echo Date("Y-m-d h:i:s",Mktime(0, 0, 0,Date("M") -1,1,Date("Y")), "\ n"; + Echo Date("Y-m-d h:i:s",Mktime(23,59,59,Date("M"), 0,Date("Y")), "\ n"; A Echo' <br> this month:<br> '; at Echo Date("Y-m-d h:i:s",Mktime(0, 0, 0,Date("M"), 1,Date("Y")), "\ n"; - Echo Date("Y-m-d h:i:s",Mktime(23,59,59,Date("M"),Date("T"),Date("Y")), "\ n"; -   - $getMonthDays=Date("T",Mktime(0, 0, 0,Date(' n ') + (Date(' n ')-1)%3,1,Date("Y")));//number of days in the quarter not last month - Echo' <br> this quarter:<br> '; - Echo Date(' Y-m-d h:i:s ',Mktime(0, 0, 0,Date(' n ')-(Date(' n ')-1)%3,1,Date(' Y ')), "\ n"; in Echo Date(' Y-m-d h:i:s ',Mktime(23,59,59,Date(' n ') + (Date(' n ')-1)%3,$getMonthDays,Date(' Y ')), "\ n";

Transferred from: http://www.cnblogs.com/whlives/p/5795458.html

Get the code for this week, last week, this month, last month, this quarter date with PHP

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.