Inserting mm/dd/yyyy format dates in MySQL

后端 未结 2 574
渐次进展
渐次进展 2020-12-10 08:03

How can I insert an MM/DD/YYYY format date into an MySQL database using PHP?

2条回答
  •  没有蜡笔的小新
    2020-12-10 08:41

    This can be done using STR_TO_DATE.

    Example:

    INSERT INTO useless_table (id, date_added) VALUES(
                1, STR_TO_DATE('03/08/2009', '%m/%d/%Y'));
    

    EDIT: Please also consider MarkR's solution, because it's the right thing to do[tm].

提交回复
热议问题