您可以使用GroupBy函数使其正确
$regs = DB::table('registrations')->select('createddatetime', DB::raw('COUNT(id) as count'))->get();$regs = $regs->groupBy(function($reg){ return date('H',strtotime($reg->createddatetime));});echo '<pre>';print_r($regs);
您可以使用GroupBy函数使其正确
$regs = DB::table('registrations')->select('createddatetime', DB::raw('COUNT(id) as count'))->get();$regs = $regs->groupBy(function($reg){ return date('H',strtotime($reg->createddatetime));});echo '<pre>';print_r($regs);