根据年份以及周数来获取该周的周日到周六的日期(周日为一个星期的第一天)

function getWeekDate($year,$weeknum){ 
  $firstdayofyear=mktime(0,0,0,1,2,$year); 
  $firstweekday=date('w',$firstdayofyear); 
  $firstweenum=date('W',$firstdayofyear); 
  if($firstweenum==1){ 
      $day=(1-($firstweekday-1))+7*($weeknum-1); 
      $sun=date('Y-m-d',mktime(0,0,0,1,$day,$year)); 
      $mon=date('Y-m-d',mktime(0,0,0,1,$day+1,$year)); 
      $tues=date('Y-m-d',mktime(0,0,0,1,$day+2,$year)); 
      $wed=date('Y-m-d',mktime(0,0,0,1,$day+3,$year)); 
      $thurs=date('Y-m-d',mktime(0,0,0,1,$day+4,$year)); 
      $fri=date('Y-m-d',mktime(0,0,0,1,$day+5,$year)); 
      $sat=date('Y-m-d',mktime(0,0,0,1,$day+6,$year)); 
  }else{ 
      $day=(9-$firstweekday)+7*($weeknum-1); 
      $sun=date('Y-m-d',mktime(0,0,0,1,$day,$year)); 
      $mon=date('Y-m-d',mktime(0,0,0,1,$day+1,$year)); 
      $tues=date('Y-m-d',mktime(0,0,0,1,$day+2,$year)); 
      $wed=date('Y-m-d',mktime(0,0,0,1,$day+3,$year)); 
      $thurs=date('Y-m-d',mktime(0,0,0,1,$day+4,$year)); 
      $fri=date('Y-m-d',mktime(0,0,0,1,$day+5,$year)); 
      $sat=date('Y-m-d',mktime(0,0,0,1,$day+6,$year)); 
  } 
     
  return array($sun,$mon,$tues,$wed,$thurs,$fri,$sat);     
}

 

posted @ 2019-10-24 12:47  秋风飒爽  阅读(411)  评论(0编辑  收藏  举报