PHP获取接下来一周的日期

php

浏览数:304

2019-1-7

    //获取接下来一周的日期
    function GetWeeks() {
        $i=0;
         $weeks=[];
        for ($i;$i<=7;$i++){
            $month=date('m',time()+86400*$i).'月';
            $day=date('d',time()+86400*$i).'日';
            $week=date('w',time()+86400*$i);
            if ($week=='1'){
                $week='周一';
            }elseif ($week=='2'){
                $week='周二';
            }elseif ($week=='3'){
                $week='周三';
            }elseif ($week=='4'){
                $week='周四';
            }elseif ($week=='5'){
                $week='周五';
            }elseif ($week=='6'){
                $week='周六';
            }elseif ($week=='0'){
                $week='周日';
            }
            array_push($weeks,$month.$day."(".$week.")");
        }
         return $weeks;

    }