Jump to content

How do insert date() into mysql db?


blew

Recommended Posts

guys, im having a problem here thats making me crazy

 

im making a system and i want to insert the current date in the mysql. I have the field called 'data' in the DB, but when i make the code to insert all the other fields, including the 'data', its work perfectly... unless that damn date!

 

$query = "INSERT INTO news (id, titulo, mensagem, data) VALUES (NULL, '$titulo', '$mensagem', 'date(\"d/m/Y\")')";

 

whats wrong with that?

its stores in DB as '0000-00-00'.

:wtf:

 

Link to comment
https://forums.phpfreaks.com/topic/226781-how-do-insert-date-into-mysql-db/
Share on other sites

Hopefully the data type for the field is DATE or DATETIME as it should be, then you simply use MySQL's NOW() function.

 

yep, the field is set as DATE, and i used NOW() , but this is still inserting as 0000-00-00

 

arrrghhh

http://colalinux.blogspot.com/2011/02/insert-date-into-mysql-table.html

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.