I am trying to insert 2 dates in UK format (dd/mm/yyyy) to a MySQL database in the MySQL US date format.
I am using str_to_date. The first instance of str_to_date works as expected, but the second instance always inserts the same date as the first instance of str_to_date, even though the original dates are different.
$date_1 = "10/01/2016";
$date_2 = "16/02/2016";
$sql = "INSERT INTO customers (date_1, date_2)
VALUES (STR_TO_DATE( '$date_1', '%m/%d/%Y %h:%i' ), STR_TO_DATE( '$date_2', '%m/%d/%Y %h:%i' ))";
What is the correct way of handling multiple instances of str_to_date in a MySQL insert statement?
Thank you