Skip to content
Advertisement

Why would SQL update the date into tabel to 0000-00-00 00:00:00?

I am trying to update the field SEEN in a SQL table to the current time and date.

Here is the code:

JavaScript

It sets my SEEN field to 0000-00-00 00:00:00. If I write a specific date directly into the query, say “2021-03-10 02:30:00” it would write that date into the SEEN field. But instead of $now, it would output 0s. And $now is fine, it outputs the correct timestamp.

Advertisement

Answer

The format you are using is not the same that MySQL DATETIME uses:

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