Possible Duplicate:
Inserting mm/dd/yyyy format dates in MySQL
Users are filling out a form for birthdate in this format MM-DD-YYYY.
I want to insert it into My SQL database in SQL Date format, YYYY-MM-DD.
What is the easiest way to change it? I considered doing a MID function, but was hoping to use something more efficient.
Thanks in advance!
***Yes this was answered before, but I was unable to find it, Thanks for the link!
Try this:
$sql = "INSERT INTO `my_database` (`my_date_field`) VALUES (STR_TO_DATE('".$my_date."', '%Y-%m-%d'));";