Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

Validating a Date

$
0
0

OK, so i want my form adds a persons details to a DB, all good so far but i want to grab a birth-date with the form then input that to my DB. mySQL only accepts yyyy-mm-dd format so i need to convert my string to that format no-matter what.

 

But what if the person doesn't enter the date correctly? what if the date doesn't even exist?

 

I could 'guide' the user into inputting into the form in the correct format but Ive never seen this done on line anywhere. Everywhere ive ever enter a date has always accepted:

 

dd-mm-yy

dd-mm-yyyy

mm-dd-yy

mm-dd-yyyy

 

I can probably figure out formatting to mySQL format by myself but im totally confused by what i should do when the user enters a date like:

01-03-88

is this 1st March 1988 Or 3rd January 1988?

 

Is there a setting i can grab from the browser to determine where in the world a user is?

 


Viewing all articles
Browse latest Browse all 13200

Trending Articles