日期比较目前不准确

时间:2018-02-11 17:52:07

标签: php

我正在尝试将datetime字段与订阅检查的当前日期进行比较,但日期未通过检查

<?php if($membership['membership']=='Free'){?>
    <p style="color:red;">
<?php
    //if the date of the current subscriptions his hit expire it and show that account has expired.

    $expiredate=  $usbexpiredate ;
    $currentdate =  date('Y/m/d');

    echo "Date Now".$currentdate;           
    echo "Expire Date".$expiredate;

即使今天早于2018-02-28 12:41:57过期日期,仍然会暂停订阅过期消息。我可以问为什么数据库中的日期存储为日期时间。

   if ($currentdate  > $expiredate)              
   {            
         //if it has expired we wish to downgrade the account automatically 
         // and set the isexpired flag to true

        $sql="UPDATE users SET memid='1' ,isexpierd='1' WHERE 
        useremail='$uemail'";
        mysql_query($sql);
       $message = "Subscription has expired. Please click below to renew subscription";         
  }else{
             $message =  "Subscription Expires: ".date('m/d/Y', strtotime($usbexpiredate));

  }

echo $message;

 ?>

但是出于某种原因,即使过期日期设置为2018-02-28 12:41:57,我也会将检查失败,并且我正在与今天的日期进行比较,以了解它失败的原因。

0 个答案:

没有答案