php获取本周的日期

2021-07-17  本文已影响0人  风度翩翩的程序猿
 public function get_week($time = '', $format = 'Y-m-d')
    {
        $time = $time != '' ? $time : time();
        //获取当前周几
        $week = date('w', $time);
        $date = [];
        for ($i = 1; $i <= 7; $i++) {
            $date[$i] = date($format, strtotime('+' . $i - $week . ' days', $time));
        }
        return $date;
    }
上一篇下一篇

猜你喜欢

热点阅读