<?php
header('Content-type: text/html; charset=utf-8');
$date=date("Y-m-d"); //当前日期
$first=1; //$first =1 表示每周星期一为开始日期 0表示每周日为开始日期
$w=date('w',strtotime($date)); //获取当前周的第几天 周日是0周一到周六是1-6
$now_start=date('Y-m-d',strtotime("$date -".($w==0 ? 6 : $w - $first).' days')); //获取本周开始日期,如果$w是0,则表示周日,减去6天
$now_end=date('Y-m-d',strtotime("$now_start +6 days")); //本周结束日期
echo '本周开始日期:'.$now_start." ".intval(date('YW',strtotime($now_start))).'<br />';
echo '本周结束日期:'.$now_end." ".intval(date('YW',strtotime($now_end))).'<br />';
$weekEndCnt=1;
$weekStCnt=7;
echo "<br />";
for($i=0;$i<10;$i++){
$last_start=date('Y-m-d',strtotime("$now_start - ".$weekStCnt." days"));//开始日期
$last_end=date('Y-m-d',strtotime("$now_start - ".$weekEndCnt." days")); //结束日期
echo '第'.$i.'开始日期:'.$last_start.'<br />';
echo '第'.$i.'结束日期:',$last_end,'<br />';
$weekStCnt+=7;
$weekEndCnt+=7;
echo "<br />";
}
?>