Mickey Mickey - 8 months ago 43
MySQL Question

Converting a date from bootstrap date picker to fit mysql date

How can I convert the bootstrap date-picker date to fit the mysql date.
Here is one example how i get the date from my date-picker

"11/16/2016 6:12 AM"

.How can i convert it to this date format

"0000-00-00 00:00:00"

I'm working in php here ,i have came to this part where i need to store this date ,but I'm unable to convert it that it fits the date format from the database.


If you use PHP version >= 5.3 or PHP 7, you can do something like this:

$date = date_create_from_format("m/d/Y G:i A", "11/16/2016 6:12 AM");
echo date_format($date, "Y-m-d H-i-s");

And checkout the docs page to see all the format variables.