note 89331 deleted from function.checkdate by danbrown

From: Date: Tue, 03 Mar 2009 20:56:42 +0000
Subject: note 89331 deleted from function.checkdate by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-151420@lists.php.net to get a copy of this message
Note Submitter: sebagr [at] gmail (dot) com ---- While trying to validate user input in an easy way, I came up with this idea: convert user input using strtotime, then convert back using desired format to validate with and compare. Of course you could change it to use time as well. Hope you find it useful: <?php $input = '2009-03-03'; $date_format = 'Y-m-d'; $time = strtotime($input); echo "Is valid? " date($date_format, $time) != trim($input); ?>

« previous php.notes (#151420) next »