dimanche 12 juin 2016

Comparing date time todays date against date created

I'm stuck, been reading several places regarding comparing date and date time, but still can't figure out how to do it, anyone that could be so kind to help me out?

Thing is that I'm building a membership database and when the user register an account, it inserts date time to SQL, and that membership only last 1 year. So the user has access to the page 1 year from the user registered.

Found this when reading, but not sure how I can check if the user still has access from the user registered. (365 days)

$today = date("Y-m-d H:i:s");
$expire = $isCreated; //from db

$today_time = strtotime($today);
$isCreated_time = strtotime($isCreated);

if ($isCreated_time < $today_time) { 
/* has access*/ 
} else { 
/* no access */ 
}

Thank's for all help or point in right way.

Aucun commentaire:

Enregistrer un commentaire