php获取最近7天的日期

    function getDateSeven($time = '', $format = 'Y-m-d')
    {
        $time = $time != '' ? $time : time();
        //获取当前周几
        // $week = date('w', $time);
        $date = [];
        for ($i = 0; $i <= 6; $i++) {
            $date[$i] = date($format, strtotime('-' . $i . ' days', $time));
        }
        return $date;
    }

 

posted @ 2021-08-20 11:11  一颗糊涂淡  阅读(527)  评论(0编辑  收藏  举报