-4
我想检查表格列中的时间小于当前时间10分钟。 我想在在laravel查询子句如何在列表中将列日期比当前时间少10分钟
我想检查表格列中的时间小于当前时间10分钟。 我想在在laravel查询子句如何在列表中将列日期比当前时间少10分钟
你可以尝试添加一个where子句像
SELCT * FROM MYTABLE WHERE MYCOL < NOW() - INTERVAL 10 MINUTE
让我们找到了日期时间使用PHP从当前日期时间年龄超过10分钟检查。让我们在代码中说明$ formatted_date。 而不是找到datetime小于$ formatted_date的所有记录。请看下面,让我知道你是否有任何疑问。
$date = new DateTime;
$current_date = $date->format('Y-m-d H:i:s');
$date->modify('-10 minutes');
$formatted_date = $date->format('Y-m-d H:i:s');
$result = DB::table('table_name')->where('datecolumn','<=',$formatted_date)->get();
另一种方法是:
$result = DB::table('table_name')->where(TIMESTAMPDIFF(MINUTE,'datecolumn',$current_date),'<=',10)->get();
'... WHERE your_column
1000111