我有一个由日期和时间组成的数组,其时间间隔为'x'秒,如下所示[示例1]。
我不确定编写查询以将数据从array [0]到array [1],array [2]到array [3]分组的方式。
有人可以帮我吗?谢谢。
Example 1:
array:15 [▼
0 => "'2018-11-01 00:00:00'"
1 => "'2018-11-01 00:30:00'"
2 => "'2018-11-01 01:00:00'"
3 => "'2018-11-01 01:30:00'"
4 => "'2018-11-01 02:00:00'"
5 => "'2018-11-01 02:30:00'"
6 => "'2018-11-01 03:00:00'"
7 => "'2018-11-01 03:30:00'"
8 => "'2018-11-01 04:00:00'"
9 => "'2018-11-01 04:30:00'"
10 => "'2018-11-01 05:00:00'"
11 => "'2018-11-01 05:30:00'"
12 => "'2018-11-01 06:00:00'"
13 => "'2018-11-01 06:30:00'"
14 => "'2018-11-01 07:00:00'"
15 => "'2018-11-01 07:30:00'"
]
我当前的查询如下
$testQuery = DB::Table('receipt_tbl')
// ->whereRaw('created_at IN (' . implode(',' ,$timeIntv) . ')')
->whereBetween('created_at', [ Carbon::createFromTimestamp($startDate) , Carbon::createFromTimestamp($endDate)])
->where('receipt_type', $receiptObj->id)
// ->groupBy('group_date')
->get();