Best way to validate a date
| From: | David Bevan | Date: | Wed, 09 Mar 2005 20:26:54 +0000 |
| Subject: | Best way to validate a date | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-210353@lists.php.net to get a copy of this message | ||
Hi all,
I'm looking to validate a date submitted through a
form and I cannot decide which would be the best way
to do it. The form of the date needs to be:
YYYY-MM-DD.
At the moment I'm torn between using a regex,
something like: 20[\d][\d]-[0-1][\d]-[0-3][\d]
or using the checkdate() function.
Does anyone have any pros and/or cons to implement one
method over the other or other methods you may have
used?
Thanks,
David