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

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -