我有来自MongoDB的收藏:
$collection = DB::connection('test')
->collection('test')->get();采集示例:
{ a: b, c: d, created_at: "2021-01-01 10:10:10" }
{ a: b, c: d, created_at: "2021-01-01 11:10:10" }是否可以按小时分组收集? 10..11..12等。
发布于 2021-09-07 14:21:35
我希望它能起作用
$array = [
['a' => 'b', 'c' => 'd', 'created_at' => '2021-01-01 10:10:10'],
['a' => 'b', 'c' => 'd', 'created_at' => '2021-01-01 11:10:10'],
];
$collect = collect($array);
$collect = $collect->groupBy(function($collect){
return date('H',strtotime($collect['created_at']));
});
dd($collect);https://stackoverflow.com/questions/69089465
复制相似问题