NoireNode
NoireNode

Reputation: 11

Detect membership time expiration PHP

I am trying to make an automated expiration for users who purchase membership on my website after one month (2419200 seconds)

However when I change the row's date it doesn't appear to work. I have tried wrapping the time function around different areas, even disabling it and I seem to have an issue with it working.

buyDate parameter is part of an object in my SQL database. (unix time integer) Any help would be appreciated.

<?php       
if(time($membershipExpire->buyDate) <= time($membershipExpire->buyDate + 2419200)){
        die("Your membership has expired. Please contact someone to remove your membership in order to continue playing.");
    }
?>

Upvotes: 1

Views: 250

Answers (1)

Keral Patel
Keral Patel

Reputation: 339

Rewriting it slightly different

<?php
$end = $membershipExpire->buyDate + 2419200;
if(time() >= $end)
{
die("Your membership has expired. Please contact someone to remove your membership in order to continue playing.");
}
?>

I also noted that the current time has to be greater than endtime while in your original code you were using smaller than sign.

One more thing which is not related to the code. Your error message says "Your membership has expired. Please contact someone to remove your membership in order to continue playing."

Shouldn't it be "renew your membership"?

Upvotes: 1

Related Questions