php - comparing date text field to todays date -


hope can help, have following code check both, if date field valid, , has happened in past. valid format part works keeps saying date in future (and therefore unacceptable) regardless of whether or isn't. missing here?

  if($_post['dateofcall']!=null)   {       $dt = $_post['dateofcall'];       $array = explode("/",$dt);        $day = $array[1];       $month = $array[0];       $year = $array[2];        if(!checkdate( $day,$month, $year))       {      echo '<script type="text/javascript">'    ,   'alert ( "not valid date of call" );'    , '</script>';     }       else       {       $today = date("d/m/y");       if(strtotime($dt)>$today)       echo '<script type="text/javascript">'    ,   'alert ( "date of call in future..." );'    , '</script>';     }   }      } 

thankyou in advance!

you mix dates in different formats. strtotime returns integer (unix timestamp) while date returns textual representation (string). replace date("d/m/y") time() , work.


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -