不说了,对于PHPer来说,写不出来说什么都是白瞎,不喜勿喷~~~~ 

function get_week(){
        $data = [];
        $format='Y-m-d';
        for ($i=0; $i<7; $i++){
            $strtotime = strtotime( '+' .$i.' days');
            $data[$i]['date'] = date($format ,$strtotime);
            $data[$i]['week'] = "周" . mb_substr( "日一二三四五六",date("w" ,$strtotime),1,"utf-8" );
        }
        $data[]=['date'=>date($format,strtotime( '+7 days')),'week'=>'随时'];
        return $data;
    }

OK,效果,

Array
(
    [0] => Array
        (
            [date] => 2019-01-09
            [week] => 周三
        )

    [1] => Array
        (
            [date] => 2019-01-10
            [week] => 周四
        )

    [2] => Array
        (
            [date] => 2019-01-11
            [week] => 周五
        )

    [3] => Array
        (
            [date] => 2019-01-12
            [week] => 周六
        )

    [4] => Array
        (
            [date] => 2019-01-13
            [week] => 周日
        )

    [5] => Array
        (
            [date] => 2019-01-14
            [week] => 周一
        )

    [6] => Array
        (
            [date] => 2019-01-15
            [week] => 周二
        )

    [7] => Array
        (
            [date] => 2019-01-16
            [week] => 随时
        )

)

  

 

posted on 2019-01-09 11:06  夏沫忆香  阅读(809)  评论(0编辑  收藏  举报