gpt4 book ai didi

php - 获取上一小时和当前小时内插入 MySQL 表的值

转载 作者:可可西里 更新时间:2023-11-01 08:40:40 25 4
gpt4 key购买 nike

我正在使用 Laravel 5 执行此操作。我想获取在上一小时和当前一小时内插入到 MySQL 表中的行。

enter image description here

时间列datetime格式是这样的:2015-11-11 08:34:25,我想获取当前时间并获取当前时间插入到表中的数据。我该怎么做?

现在我已经编辑了我的代码

现在我已经编辑了 enter image description here

没有错误,但不是在最后一小时和当前小时获取行

最佳答案

我已经解决了这样的问题

enter code here 
$currentHour=carbon::now()->toTimeString();
$lasthour=carbon::now()->subHour()->toTimeString();

$RecentTrips=DriverTrips::select('*')
->where('driverid',$id)
->where('date',$dateoFTrip)
->where(function($query){

$query->orwhere('status','=','accepted')
->orwhere('status','=','late');
})

->where(function($query)use ($currentHour,$lasthour){

$query ->whereRaw('TIME(time) <?',[$currentHour])
->whereRaw('TIME(time) >?',[$lasthour]);
})

->get();

关于php - 获取上一小时和当前小时内插入 MySQL 表的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33644292/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com