php根据周期获取日期时间

根据周期转化日期时间 代码如下:

 public  function getWeekDate($year,$weeknum){  
        $firstdayofyear=mktime(0,0,0,1,1,$year);  
        $firstweekday=date('N',$firstdayofyear);  
        $firstweenum=date('W',$firstdayofyear);  
        if($firstweenum==1){  
            $day=(1-($firstweekday-1))+7*($weeknum-1); 
            $startdate=date('Y-m-d',mktime(0,0,0,1,$day,$year));  
            $enddate=date('Y-m-d',mktime(0,0,0,1,$day+6,$year));  
        }else{  
            $day=(9-$firstweekday)+7*($weeknum-1);  
            $startdate=date('Y-m-d',mktime(0,0,0,1,$day,$year));  
            $enddate=date('Y-m-d',mktime(0,0,0,1,$day+6,$year)); 
        }  
          
        return array($startdate,$enddate);      
}  

$year为年份,$weeknum为周数 使用方法: $this->getWeekDate(2017,23);//23为第23周