Insert current date in datetime format mySQL

后端 未结 15 1163
梦谈多话
梦谈多话 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:12

    If you're looking to store the current time just use MYSQL's functions.

    mysql_query("INSERT INTO `table` (`dateposted`) VALUES (now())");
    

    If you need to use PHP to do it, the format it Y-m-d H:i:s so try

    $date = date('Y-m-d H:i:s');
    mysql_query("INSERT INTO `table` (`dateposted`) VALUES ('$date')");
    

提交回复
热议问题