admin管理员组文章数量:1130762
I have this code in my custom plugin. It's supposed to check if a timestamp is older than 24 hours
$today = new DateTime();
foreach( $customers_to_activate as $customer_details ){
$time = $customer_details['approved_date']; //this is a timestamp stored into usermeta
$registration_date = new DateTime("@$time"); //converting the timestamp into a DateTime object
$interval = $today->diff($registration_date); //checking if the timestamp is older than 24 hours
if( $interval->days > 1 && empty($customer_details['last_password_reset']) && !(bool)$customer_details['account_details_sent'] || empty($customer_details['account_details_sent']) ){ //code stuff here }
}
I've noticed that the check will not occur correctly and a test account I've registered today will get an email from my wordpress system before 24hours are elasped. Is there something wrong into the code?
本文标签: phpcheck difference between two timestamp in custom plugin
版权声明:本文标题:php - check difference between two timestamp in custom plugin 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736758388a1951410.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论