Get the timestamps of Monday and Sunday
You can see a lot of things through the following two examples of extracting the timestamps of Monday and Sunday. You need to keep thinking. The first one is better to extract the timestamp of the specified date, but how to extract the timestamp of Monday and Sunday? The second one is more practical.
*/
function getmonsun(){ $curtime=time(); $curweekday = date('w'); //为0是 就是 星期七 $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']); //方法二 利用php strtotime函数 echo strtotime('last monday'); echo '<br />'; echo strtotime('next sunday');