我有关于strotime()函数的问题。
我的代码如下: (PHP PDO MySQL)
$BasketLastDate = date('Y-m-d H:i:s',strtotime('+7 minutes'));
$BasketLastDate = strtotime($BasketLastDate);
$sepetONAY = 0;
$sg = "SELECT * FROM baskets WHERE approve=1 and checkout=0";
foreach($db->query($sg) as $basketDetails){
$BasketDate = $basketDetails['basket_date'];
$BasketDate = strtotime($BasketDate);
// If the basket older than 7 minutes
if ($BasketLastDate < $BasketDate){
// code....
}
如果记录早于7分钟,则代码应查找所有行并更改情况。但这没有发生。
请帮助我。
最佳答案
我认为您应该在7分钟之前检查时间,而不是在以下时间:
$BasketLastDate = date('Y-m-d H:i:s',strtotime('-7 minutes'));
关于php - 使用PHP和strtotime()函数在mysql上查找和更改数据,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/44390371/