note 77708 deleted from ref.regex by felipe
| From: | felipe@php.net | Date: | Mon, 10 Dec 2007 02:31:44 +0000 |
| Subject: | note 77708 deleted from ref.regex by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-133118@lists.php.net to get a copy of this message | ||
Note Submitter: goran at extensionsforjoomla dot com
----
@regex - off-topic date validator yyyy-mm-dd (mySQL date format)
try validating 2008-01-31 and it will fail.
Perhaps using core PHP functions and simple solutions could be better approach:
function validateDate($date)
{
if (preg_match('/^(\d{4})-(\d{2})-(\d{2})$/', $date, $datebit)) :
if (true === checkdate($datebit[2] , $datebit[3] , $datebit[1])) :
return $date;
endif;
else :
return false;
endif;
}