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