php 獲取將來七天的日期和星期

php獲取將來七天的日期和星期代碼php

    for($i=4;$i<8;$i++){code

      $dateArray[$i]=date('Y-m-d',strtotime(date('Y-m-d').'+'.$i.'day'))blog

    };get

    $b=array();io

    foreach($dateArray as $key=>$value){function

       $b[]=array('id'=>$key,'date'=>$value)class

    };date

    foreach($b as $k=>$v){foreach

       $b[$k]['week']=get_week($v['date']);im

       $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];

    }

相關文章
相關標籤/搜索