我有一个 Laravel 4 加入,如下所示:
return DB::table(Location::getTableName() . ' as l')->where('l.company_id', $companyId)
->join(User::getTableName() . ' as u', 'u.location_id', '=', 'l.id')->whereIn('l.id', $locationsId)
->join(UserTimeline::getTableName() . ' as ut', 'ut.user_id', '=', 'u.id')
->join(Status::getTableName() . ' as s', 's.id', '=', 'ut.status_id')
->select(
'l.name as location_name',
'u.first_name as user_first_name',
'u.last_name as user_last_name',
'u.email as user_email',
'ut.started_at as timeline_started_at',
'ut.finished_at as timeline_finished_at',
's.id as status_id',
's.label as status_label'
)
->orderBy('ut.id', 'asc')
->skip($from)
->limit($limit)
->get();
我必须检测用户的时区并将与 GMT 的差异计算为一个数字,巴基斯坦可能是 +5,印度可能是 +5.5。现在我的问题是我正在将此连接的数据导出到 CSV 文件中。我必须在“timeline_started_at”和“timeline_finished_at”中添加小时数。我搜索并发现 SQL 的“DATEADD”方法可以增加或减少小时数。
真正的问题是我不知道在上面的连接中我应该在我的 Laravel 连接中使用 'DATEADD' 函数。
有人可以在这方面帮助我吗?????????