自定日期作为条件查询前七天日期

被刻印的时光 ゝ 提交于 2019-12-16 01:13:31

前七天

 public function day($week_start) {
        $week_start = "201912";
        $statistics = [];
        for ($i = 7; $i >= 0; $i--) {
            $statistics[] = date('d', strtotime("$week_start -$i days"));
        }

 dump($statistics);exit;
        return $statistics;
    }

 

前12个月

public function period($week_start) {
        $week_start = "201912";
        $statistics = [];
        for ($i = 11; $i >= 0; $i--) {
            $statistics[] = date('Ym', strtotime("$week_start -$i month"));
        }

 dump($statistics);exit;
        return $statistics;
    }

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!