--- Wade Smart <[EMAIL PROTECTED]> wrote:

> Im working on some form validation. In this one field, the dob field, Im
> having to make sure that a dob is both correctly formatted and is valid.
> 
> For example, a user could put in
> 01-01-2008
> 1-1-2008
> 01 01 2008
> 1 1 2008
> or
> 01012008
> 112008
> 
> and that assumes Month Day Year format.
> 
> Now, the range of options are many:
> D M YY
> D M YYYY
> DD MM YYYY
> 
> MM DD YYYY
> M D YYYY
> M D YY
> 
> and my client wants to make sure that in any case we catch the dob, format it
> correctly and then put it in the db.
> 
> Im curious to what others to in this situation.
> 
> Wade

Although it is not perfect, the strtotime() function will handle many of these
inputs for dates on or after 1 Jan 1970 on most LAMP systems.  Earlier dates
may show 31 Dec 1969 for all values.

You could use strtotime() as part of an overall date validation scheme.  Other
steps may be necessary to cover other contingencies.

James
 

Reply via email to