php 获取未来七天的日期和星期
php获取未来七天的日期和星期代码
for($i=4;$i<8;$i++){
$dateArray[$i]=date('Y-m-d',strtotime(date('Y-m-d').'+'.$i.'day'))
};
$b=array();
foreach($dateArray as $key=>$value){
$b[]=array('id'=>$key,'date'=>$value)
};
foreach($b as $k=>$v){
$b[$k]['week']=get_week($v['date']);
$b[$k]['date']=substr($v['date'],5);
}
function get_week($date){
$date_str=date('Y-m-d',strtotime($date));
$arr=explode("-", $date_str);
$year=$arr[0];
$month=sprintf('%02d',$arr[1]);
$day=sprintf('%02d',$arr[2]);
$hour = $minute = $second = 0;
$strap = mktime($hour,$minute,$second,$month,$day,$year);
$number_wk=date("w",$strap);
$weekArr=array("周日","周一","周二","周三","周四","周五","周六");
return $weekArr[$number_wk];
}