获取最近一周

        $weeks =['周日','周一','周二','周三','周四','周五','周六'];
        $dates=[
            'statistics_date <= '=>date("Y-m-d",strtotime("-1 day")),
            'statistics_date >= '=>date("Y-m-d",strtotime("-7 day"))
        ];
        $res=array();
        //过去7天生成数组
        for($i=7,$j=0;$i>0;$i--,$j++){
            $time=date("Y-m-d",strtotime("-".$i." day"));
            $list[$time]=$j;
        }
        //过去7天转换为星期
        foreach($list as $key=>$val){
            $d = date("w",strtotime($key));
            $w = $weeks[$d];
            $res[$w]=$w;
        }

猜你喜欢

转载自www.cnblogs.com/xiaobiaomei/p/10958757.html
今日推荐