如何基于laravel的created_at和其他字段获取小时数

时间:2019-05-30 08:18:04

标签: php laravel

在我的应用中,我想获取基于socket_itcreated_at的驱动程序在线小时数。我怎样才能做到这一点?有人帮助我,谢谢。这是我的桌子

enter image description here

结果如下:

enter image description here

$query = DB::table('tms_time_logs');
$query->where('tms_time_logs.user_id', 170);
$query->where('tms_time_logs.type', 'driver');
$query->orderBy('tms_time_logs.id', 'DESC');
$query->groupBy(DB::raw('Date(tms_time_logs.created_at)'));
$query->groupBy('tms_time_logs.socket_id');
$query->select(DB::raw('count(*) as count, HOUR(created_at) as hour'));
$performances = $query->get();

0 个答案:

没有答案