源码

$time = time();
$n = intval(date('N', $time));// 1-7 monday-sunday

echo '今日:'.date('Y-m-d (N)', $time).PHP_EOL;

echo '上周一:'.date('Y-m-d (N)', $time-(6+$n)*24*60*60).PHP_EOL;
echo '下周六:'.date('Y-m-d (N)', $time+(7-$n+6)*24*60*60).PHP_EOL;

echo '上周一:'.date('Y-m-d (N)', strtotime('monday last week')).PHP_EOL;
echo '下周六:'.date('Y-m-d (N)', strtotime('saturday next week')).PHP_EOL;

测试效果

图片描述


klinson
141 声望12 粉丝