Obtain the timestamp of Monday and Sunday.
We can see a lot of things through the following two examples of getting timestamps from Monday and Sunday. We need to keep thinking that it is better to get the timestamp of the specified date first, but how to retrieve the second one on Monday and Sunday is more practical.
*/
Function getmonsun () {$ curtime = time (); $ curweekday = date ('W'); // if it is set to 0, it means week 7 $ curweekday = $ curweekday? $ Curweekday: 7; $ curmon = $ curtime-($ curweekday-1) * 86400; $ cursun = $ curtime + (7-$ curweekday) * 86400; $ cur ['mon'] = $ curmon; $ cur ['sun'] = $ cursun; return $ cur ;}$ cur = getmonsun (); echo date ('Y-m-d', $ cur ['mon']); echo "rn"; echo date ('Y-m-d ', $ cur ['sun']); // method 2 use the php strtotime function echo strtotime ('Last Monday'); echo '<br/> '; echo strtotime ('Next Sunday ');