determine whether an acocunt is expired PHP -
how determine account expired.
the expiry date of account stored in format "dd/mm/yyyy"
for example user has expiry date of "12/8/2012" how can compare today's date , find out expired account using php?
i tried
$expiry = strtotime("12/8/2012"); $now = new datetime(); echo ($now < $expiry ? 'active' : 'expired');
it shows me error where
object of class datetime not converted int
yuo can use date
function , strtotime
function
$today = date('y-m-d h:i:s'); $expiry = date('y-m-d h:i:s', strtotime("12/8/2012")); if($today >= $expiry) { echo 'account expired'; } else { echo 'account still valid.'; }
this output
account expired
Comments
Post a Comment