ceil((strtotime('now')-1483228800)/7/60/60/24)-ceil((Yii::$app->params['term_start_date']-1483228800)/7/60/60/24)+1app
如下是測試代碼測試
function prDates($start,$end,$term_start){ // 兩個日期之間的全部日期
$dt_start = strtotime($start);
$dt_end = strtotime($end);
while ($dt_start<=$dt_end){code
echo date('Y-m-d',$dt_start).'今天是:'.date('N',$dt_start).'第幾周:'.(ceil(($dt_start-strtotime('2017-01-01'))/7/60/60/24)-ceil(($term_start-strtotime('2017-01-01'))/7/60/60/24)+1)."\n"; if(date('N',$dt_start)==7){echo "\n";} $dt_start = strtotime('+1 day',$dt_start); }
}io
$b=strtotime('2018-09-01'); $a=strtotime('2017-03-13'); prDates('2018-09-01','2019-01-12',$b);function