Question

my website using php activerecord to handle the sql and there're three field inside the db: joindate,status,activatecode

all registered member must activated in 24 hours,otherwise account will be deleted

how to write the php code to do this function? the joindate now using php date('Y-m-d'). also the code can automatic work without manually launch

Was it helpful?

Solution

In order to get an accurate 24 hr deactivation, you will need to change the joindate sql field to type "datetime" which will also hold the time. Then use this code:

// In the following statement, $JoinDate holds the sql `joindate` field
$timeDiff = time() - strtotime($JoinDate);

if($timDiff/3600 > 24) {
    // code to be executed if it's past the 24 hrs period
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top