echo Date ("Ymd", Strtotime ("Now"), "\ n", Echo date ("Ymd", Strtotime ("1 week Monday"), "\ n", Echo date ("Ymd", Strtotime ( "-1 week Sunday")), "\ n", Echo date ("Ymd", Strtotime ("+0 Week Monday"), "\ n", Echo date ("Ymd", Strtotime ("+0 Week Sunday") , "\ n"; Date (' n ') months//date ("W") weeks of the week//date ("T") this week the number of days 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"; 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 "; Echo ' <br> this month:<br> '; 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"));//Last month of the quarter 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"; Echo date (' y-m-d h:i : S ', Mktime (23,59,59,date (' n ') + (date (' n ')-1)%3, $getMonthDays, date (' Y '))), "\ n";
Get the code for this week, last week, this month, last month, this quarter date with PHP