php - Can't insert datetime to MySql -


This is strange when I get a date time: $ date = date ("Ymd H: i : S "); and try putting it into the database, it will insert null . The column I inserted is a datetime. It does not matter which column I change the data, it will still include zero.

I hope someone can help me!

Because column

in your query instead of a routine
  $ sql = "... datefield = '$ date' ....";  

do

  $ sql = "... datefield = TIMESTAMP ('$ date') ....";  

Obviously .... represents your SQL at that point.


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -