根据周日获取这周的周日到周六的日期(周日为这周的第一天)

//获取相应周的开始时间(星期日)到(周六)
function getWeekDate($year,$mon,$day){ 
  $date1=$year.'-'.$mon.'-'.$day;
  $sun=$date1;
  $mon=date('Y-m-d',strtotime("$date1 +1 day")); 
  $tues=date('Y-m-d',strtotime("$date1 +2 day")); 
  $wed=date('Y-m-d',strtotime("$date1 +3 day")); 
  $thurs=date('Y-m-d',strtotime("$date1 +4 day"));
  $fri=date('Y-m-d',strtotime("$date1 +5 day")); 
  $sat=date('Y-m-d',strtotime("$date1 +6 day")); 
     
  return array($sun,$mon,$tues,$wed,$thurs,$fri,$sat);     
}

代码的参数为年月日三项,可以更改成一个参数(周日的日期)

原文地址:https://www.cnblogs.com/leaf-blog/p/11731570.html