The current date is [2016/06/14 Tuesday]
Then the time range last week is [2016/06/06]-[2016/06/12]
Only the current date has not been completed (that is, Sunday this week has not been completed)
Then last week will always be【2016/06/06】-【2016/06/12】
How to get the time range of last week in php
The current date is [2016/06/14 Tuesday]
Then the time range last week is [2016/06/06]-[2016/06/12]
Only the current date has not been completed (that is, Sunday this week has not been completed)
Then last week will always be【2016/06/06】-【2016/06/12】
How to get the time range of last week in php
Use strtotime, check the manual for details. Example date('Y-m-d', strtotime('-1 week'))
gets the week before the current time, the month is also date('Y-m-d', strtotime('-1 month'))
, and the day and year are also available.
echo date("Y-m-d",strtotime('-1 week last monday'))." 00:00:00";
echo date("Y-m-d",strtotime('last sunday'))." 23:59:59";
<code>echo '<br>上周起始时间:<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";</code>