-The 1 Monday output is the time of this Monday, which is very strange.-1 Monday output is the time of this Monday, which is very strange.
Reply content:
-1 the Monday output is the Monday time, which is very strange.
Because foreigners think that "this Monday" is next Monday and "last Monday" is this Monday
Simply "-2 Monday", or "Monday last week"
Date ('Y-m-D', strtotime ('-'. (6 + date ('w'). 'days '));
-7 days
last week
It usually takes two steps to obtain any day of the last week and then Monday, just as finding the first day of the next month at the end of the month and then-1 day.
Write a general method.
function last_monday($timestamp=0,$is_return_timestamp=true){ static $cache ; $id = $timestamp.$is_return_timestamp; if(!isset($cache[$id])){ if(!$timestamp) $timestamp = time(); $thismonday = this_monday($timestamp) - /*7*86400*/604800; if($is_return_timestamp){ $cache[$id] = $thismonday; }else{ $cache[$id] = date('Y-m-d',$thismonday); } } return $cache[$id]; }
Date ('w') gets the current day of the week, because Monday to Saturday is 1-6, and Sunday is 0. When the value is 0, last Monday is 13 days ago. The rest are date ('w') + 6 days ago.
$days = date('w')==0?13:date('w')+6;echo date('Y-m-d',time()-$days*86400);
Here we see the document link description
Echo "last Monday:". date ("Y-m-d", strtotime ("last Monday "))."
";
$ Time = strtotime ("-7 day ");
$ Timetest = date ("Y-m-d h: I: sa", $ time );