Skip to content
Advertisement

Inserting date in PHP prepared statements

I am trying to insert current date (in d-m-Y) in a prepared statement into mysql table. I can’t get the code right. I am calling current date in php by

JavaScript

and then including in a prepared statement like this

JavaScript

In the table, the date does not get inserted. It remains 0000-00-00. How can I rectify this?

Advertisement

Answer

You should use the YYYY-MM-DD format:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement