您可以尝试以下查询。
SELECT * FROM test WHERE res_time >= DATE_SUB(CURDATE(),INTERVAL 15 MINUTE)
If you are using PHP then you can do this
$beforeTime = date("Y-m-d h:i:s",strtotime("-15 minutes"));
$query = "select * from test where res_time >= '$beforeTime' " ;
If you want the pure SQL solution then follow other mentioned solutions.
Cheers !!!
Try this if you are not using unix timestamp:
SELECT * FROM test WHERE res_time >= DATE_SUB(CURDATE(), INTERVAL 15 MINUTE);
or
SELECT * FROM test WHERE FROM_UNIXTIME(res_time) >= DATE_SUB(CURDATE(), INTERVAL 15 MINUTE)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.