Php 在Laravel中检索更新时间比创建时间早2小时的记录(雄辩)
我想统计更新的\u比创建的\u早2小时的记录 代码 不幸的是,这不起作用,因为次小时(2)代表碳,但希望你能理解 看法 有人知道怎么做吗?使用这种方法。使用您的代码逻辑:Php 在Laravel中检索更新时间比创建时间早2小时的记录(雄辩),php,mysql,laravel,eloquent,php-carbon,Php,Mysql,Laravel,Eloquent,Php Carbon,我想统计更新的\u比创建的\u早2小时的记录 代码 不幸的是,这不起作用,因为次小时(2)代表碳,但希望你能理解 看法 有人知道怎么做吗?使用这种方法。使用您的代码逻辑: $teLang = $kentekens->filter(function($i) { return $i->updated_at->gt($i->created_at->subHours(2)); }); 使用此语句“其中更新的时间比创建的时间早2小时”: 也许是吧 public fu
$teLang = $kentekens->filter(function($i) {
return $i->updated_at->gt($i->created_at->subHours(2));
});
使用此语句“其中更新的时间比创建的时间早2小时”:
也许是吧
public function create() {
$kentekens = Kenteken::latest()
->where('created_at', '>=', Carbon::today())
->get();
$cr = Carbon::create($kentekens->created_at);
$teLang = $kentekens->where('updated_at', '>', $cr->addHours(2));
return view('layouts.dashboard', compact('kentekens', 'teLang'));
}
SQL:
是否有帮助?使用gt返回一行,该行不应包含在“created_at”=2018-01-24 16:59:12和“Update_at”=2018-01-24 17:44:32处。这不应该发生吗?
public function create() {
$kentekens = Kenteken::latest()
->where('created_at', '>=', Carbon::today())
->get();
$teLang = $kentekens->where('updated_at', '>', 'created_at'->subHours(2));
return view('layouts.dashboard', compact('kentekens', 'teLang'));
}
$teLang = $kentekens->filter(function($i) {
return $i->updated_at->gt($i->created_at->subHours(2));
});
$teLang = $kentekens->filter(function($i) {
return $i->updated_at->lt($i->created_at->subHours(2));
});
public function create() {
$kentekens = Kenteken::latest()
->where('created_at', '>=', Carbon::today())
->get();
$cr = Carbon::create($kentekens->created_at);
$teLang = $kentekens->where('updated_at', '>', $cr->addHours(2));
return view('layouts.dashboard', compact('kentekens', 'teLang'));
}
$kentekens->whereRaw('`updated_at` > DATE_ADD(`created_at`, INTERVAL 2 HOUR)');
select `id` from `tablename` where `updated_at` > DATE_ADD(`created_at`, INTERVAL 2 HOUR)