I have a Web for that requires the user to enter a date which is then stored in a MySQL database. I'd like to have the user enter the date in m/d/yyyy and have the system convert it into the Y-m-d format that MySQL requires. I thought that was simple enough, but I can't get it to stop making a serious error,
I've tried the following:
$date = new DateTime($this->vital_date);
$this->vital_date = $date->format('Y-m-d');
When the user enter 9/6/2013, 2013-06-09 gets stored in the MySQL table. (Note the transposition of the month and date.
Then, I tried the older, pre-object way:
$date = strtotime($this->vital_date);
$this->vital_date = date('Y-m-d', $date);
And that did the same thing -- a transposed month and date.
Can anyone give me any help on what I'm doing wrong or how I could make a better conversion.