The error is due to the fact that you are probably using a MySQL version prior to 5.6.5. If you can update it, this will eliminate your error.
Reference: link .
As of MySQL 5.6.5, TIMESTAMP
and DATETIME
columns can be automatically initialized and updated to the current date and time (that is, the current timestamp). Before 5.6.5, this is true only for TIMESTAMP
, and for at most one TIMESTAMP
column per table.
Translation:
As of MySQL 5.6.5, columns of type TIMESTAMP
and DATETIME
can be initialized and updated automatically with the current date and time (ie the current timestamp). Before 5.6.5, this could only be done with TIMESTAMP
, and only with a maximum of one column of type TIMESTAMP
per table.
If you can not update your MySQL, I think you only have 2 options:
Change the type of your column to TIMESTAMP
.
Use a trigger to update the field with the current date and time.