根据年份以及周数来获取该周的周日到周六的日期(周日为一个星期的第一天)
作者:互联网
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); }
标签:该周,周数,thurs,mktime,weeknum,year,date,day,周日 来源: https://www.cnblogs.com/leaf-blog/p/11731560.html