Insert current date in datetime format mySQL

后端 未结 15 1133
梦谈多话
梦谈多话 2020-12-02 05:38

I\'m having problems getting the date inserted properly into my database.

$date = date(\'m/d/Y h:i:s\', time());

I use this format, and, it

15条回答
  •  独厮守ぢ
    2020-12-02 06:35

    NOW() is used to insert the current date and time in the MySQL table. All fields with datatypes DATETIME, DATE, TIME & TIMESTAMP work good with this function.

    YYYY-MM-DD HH:mm:SS

    Demonstration:

    Following code shows the usage of NOW()

    INSERT INTO auto_ins
    (MySQL_Function, DateTime, Date, Time, Year, TimeStamp)
    VALUES
    (“NOW()”, NOW(), NOW(), NOW(), NOW(), NOW());
    

提交回复
热议问题