php检查过期日期并在1天后删除

php检查过期日期并在1天后删除,php,Php,我的目标是 如果日期过期。。。脚本给用户多出一天的时间,如果未订阅,则删除用户数据 我该怎么做?。。。我试了一天,但是。。。我不知道是否有效 // Check Expire Dates and Delete Expired 1 day after. $now = date('Y-m-d'); if ($row['expire_admin'] > $now) { echo " <a href='#' id='profileGhost'> ". $row['e

我的目标是

如果日期过期。。。脚本给用户多出一天的时间,如果未订阅,则删除用户数据

我该怎么做?。。。我试了一天,但是。。。我不知道是否有效

// Check Expire Dates and Delete Expired 1 day after.
  $now = date('Y-m-d');

  if ($row['expire_admin'] > $now)
  {
    echo " <a href='#' id='profileGhost'> ". $row['expire_admin'] . "</a>";
  }
  else
  {
    echo " <a href='#' id='profileGhost'>Expired.</a>";
    $queryExpire = "DELETE FROM public_vips WHERE expire_admin(expire_admin, INTERVAL 1 day), steamid='$steamID'";
    $expiredQ = mysqli_query($db, $queryExpire);
  }
//检查过期日期并在过期1天后删除过期日期。
$now=日期('Y-m-d');
如果($row['expire\u admin']>$now)
{
回声“;
}
其他的
{
回声“;
$queryExpire=“从公共贵宾中删除,其中expire\u admin(expire\u admin,间隔1天),steamid='$steamid';
$expiredQ=mysqli\u查询($db,$queryExpire);
}

您的SQL应该是

DELETE FROM public_vips 
WHERE expire_admin(expire_admin, INTERVAL 1 day)
    AND steamid='$steamID'
//检查过期日期并在过期1天后删除过期日期。
$now=新日期时间();
$明天=新的日期时间();
$明天->添加(新日期间隔('P1D');
$expirement\u date=DateTime::createFromFormat('Y-m-d',$row['expire\u admin']);
如果($expiration\u date->format('u')>$now->format('u'))
{
如果($expiration\u date->format('u')<$tomory->format('u'))
回声“;
}
其他的
{
回声“;
//我假设steamID是您当前检查的行的唯一id
$queryExpire=“从公共_VIP删除,其中steamid='$steamid'”;
$expiredQ=mysqli\u查询($db,$queryExpire);
}
}

$row['expire\u admin']的格式是什么?您不想现在就删除$row['expire\u admin']<$row,因为expire\u admin应该在过去(少于现在)才能删除吗?
// Check Expire Dates and Delete Expired 1 day after.
$now = new DateTime();
$tomorrow = new DateTime();
$tomorrow->add( new DateInterval( 'P1D' ) );
$expiration_date = DateTime::createFromFormat('Y-m-d', $row['expire_admin'] );

if ( $expiration_date->format('u') > $now->format('u') )
{
    if( $expiration_date->format('u') < $tomorrow->format('u') )
        echo " <a href='#' id='profileGhost'> ". $row['expire_admin'] . "</a>";
    }
    else
    {
        echo " <a href='#' id='profileGhost'>Expired.</a>";

        // I suppose that steamID is the unique id of the row you are currently check
        $queryExpire = "DELETE FROM public_vips WHERE steamid='$steamID'";
        $expiredQ = mysqli_query($db, $queryExpire);
    }
}