尝试将简单的X分钟计时器添加到订单状态.我通过设置时区,将当前UNIX时间加载到变量中,然后为触发时间添加X分钟来实现.每次页面加载时,它都会检查存储的“触发”时间并将其与当前时间进行比较.如果当前时间戳大于存储的时间戳,请继续执行下一步.无论“现在”是否小于“超时”,都将进行下一步.
$now = (int) time(); //1550450927
$overtime = strtotime(+5 minutes); //1550451222
//also tried datetime format
$now = new DateTime('now');
$overtime = $now->modify('+10 Minutes');
if ( $now >= $overtime ) { //if "overtime" has passed
//stuff happens with no regard for reality
//driving me absolutely bonkers
}
检查当前时间与请求时间的数据库输入,数字是否正确.它们的存储与UNIX时间戳示例完全相同.
解决方法:
调用Modify()会更新$now值以及$overtime值.
尝试:
$now = (int) time(); //1550450927
$overtime = strtotime("+5 minutes"); //1550451222
//also tried datetime format
$now = new DateTime('now');
$overtime = (new DateTime("now"))->modify("+5 minutes");
print_r($now);
print_r($overtime);
if ( $now >= $overtime ) { //if "overtime" has passed
echo "hit";
//stuff happens with no regard for reality
//driving me absolutely bonkers
}
标签:wordpress,php
来源: https://codeday.me/bug/20191108/2006524.html