RE: [PHP] validate date
| From: | John W. Holmes | Date: | Thu, 19 Dec 2002 17:58:39 +0000 |
| Subject: | RE: [PHP] validate date | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-128890@lists.php.net to get a copy of this message | ||
> If a user inputs a date into a form, what function can I use to
validate
> that he put in a valid date?
> I want to use checkdate but that needs the date split up into day,
month
> year.
> Anyone have an easy way of doing this?
You have to specify a date format to your users, or at least assume a
certain amount of formats. If you don't do this, then there's no way to
validate it, because any amount of variations exist of date formats.
If you require a mm/dd/yy format, then just break it apart and validate
each element. You'll basically have to write your own function, or
possibly use strtotime() to see if it returns a result.
---John W. Holmes...
PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/