Insert current date in datetime format mySQL

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

    set the type of column named dateposted as DATETIME and run the following query:

    INSERT INTO table (`dateposted`) VALUES (CURRENT_TIMESTAMP)
    
    0 讨论(0)
  • 2020-12-02 06:36

    $date = date('Y-m-d H:i:s'); with the type: 'datetime' worked very good for me as i wanted to print whole date and timestamp..

    $date = date('Y-m-d H:i:s'); $stmtc->bindParam(2,$date);

    0 讨论(0)
  • 2020-12-02 06:36

    I believe, you need to change your code little bit like follows alongside with your database filed type.

    mysql_query("INSERT INTO table (`dateposted`) VALUES ($datetime)");
    

    Hope, will work perfectly.

    0 讨论(0)
提交回复
热议问题