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