note 9543 added to checkdate
| From: | mcq at supergamez dot hu | Date: | Fri, 10 Nov 2000 06:14:27 +0000 |
| Subject: | note 9543 added to checkdate | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-7565@lists.php.net to get a copy of this message | ||
Let's assume You have to check a YYYY-MM-DD fromat date, you can do it perfectly with using
both checkdate and a little regexp just to make sure the format is correct, here it is ($ndate is
the new date):
$aux = explode ("-", $ndate);
if ((!checkdate ($aux[1],$aux[2],$aux[0]))||(!ereg("^[0-9]{4}\-[0-9]{2}\-[0-9]{2}$",
$ndate)))
{ echo "bad date<br>\n"; };
http://www.php.net/manual/function.checkdate.php