php gets the monthly order volume from January 1 to the current day

//获取每月的订单量
    public function getOrderCountByMonth(){
        $n = date('m')-1;
        $m = date('m')-2;
        for($i=1;$i<=date('m');$i++){
            $beginThismonth[$i]=mktime(0,0,0,date('m')-$n,1,date('Y'));
            $endThismonth[$i]=mktime(23,59,59,date('m')-$m,0,date('Y'));
            $allResult[$i] = Orders::where("create_time",">=",$beginThismonth[$i])->where('create_time','<',$endThismonth[$i])->count();
            $allResult[$i] = json_decode($allResult[$i]);
            $n--;
            $m--;
        }
        $result['allResult'] = $allResult;
        return $result;
    }

 

Guess you like

Origin blog.csdn.net/qq_43737121/article/details/109017284