Notes on PHP Development-commonly used date acquisition methods in weekly and weekly operations. This Monday echodate (Y-m-d, (time ()-(date (w) 0? 7: date (w)-1) * 24*3600); w is the number of the day of the week. Here 0 is the echodate (Y-m-d, (time () + (7-(date (w) 0? 7. Monday
Echo date ('Y-m-D', (time ()-(date ('w') = 0? 7: date ('w')-1) * 24*3600); // w indicates the number of weeks. 0 indicates Sunday.
This Sunday
Echo date ('Y-m-D', (time () + (7-(date ('w') = 0? 7: date ('w') * 24*3600); // w is also used, which is calculated based on the number of days Currently related to Sunday.
Last Monday
Echo date ('Y-m-D', strtotime ('-1 Monday', time (); // no matter the number of today, -1 Monday indicates the last valid week.
Last Sunday
Echo date ('Y-m-D', strtotime ('-1 Sunday', time (); // the last valid Sunday, also applies to other weeks
1st day of this month
Echo date ('Y-m-D', strtotime (date ('Y-M', time (). '-01 00:00:00'); // Generate strtotime directly
Last day of this month
Echo date ('Y-m-D', strtotime (date ('Y-M', time ()). '-'. date ('t', time ()). '00:00:00'); // t indicates the number of days in the current month, 28 to 31 days.
1st day of last month
Echo date ('Y-m-D', strtotime ('-1 month', strtotime (date ('Y-M', time ()). '-01 00:00:00'); // subtract one month from strtotime on January 1, 1st day of this month.
Last day of last month
Echo date ('Y-m-D', strtotime (date ('Y-M', time ()). '-01 00:00:00')-86400); // minus one day on January 1, 1st day of this month is the last day of the previous month.
Reprinted from http://hi.baidu.com/panez/item/bc88803f487955f2a884289d
Explain echo date ('Y-m-D', (time ()-(date ('w') = 0? 7: date ('w')-1) * 24*3600); // w is a number of the day of the week, here 0 is Sunday echo date ('Y-m-D', (time () + (7-(date ('w') = 0? 7...