After upgrade to laravel 5.3 error invalid datetime format: 1292 Incorrect datetime value: '0000-00-00 00:00:00'

Laravel 5.3 was updated to use MySQL "strict" mode by default, which includes the NO_ZERO_DATE mode.

The issue is that your existing data was allowed to have '0000-00-00 00:00:00' as a datetime value. But, now your connection is using a sql mode that does not allow that value (NO_ZERO_DATE). When you attempt to alter the table to add the deleted_at column, it is complaining about the existing data violations in the created_at column.

The ideal solution would be to fix all the data in the database. That is, go through your database and update your datetime/timestamp fields so that they are nullable, and convert their data from '0000-00-00 00:00:00' to null.

However, the quick option is to just disable "strict" mode on your database connection. Open your config/database.php file, and make sure your database connection shows 'strict' => false.


I've had the same problem when adding a datetime column in a table with timestamps (created and updated_at).

I solved just adding the '->nullable($value = true)' modifier in my migration:

$table->datetime('expires_at')->nullable($value = true);

I understood that the database complained about inserting all that zeros if the input dont come. Add the instruction to be nullable did the trick.


This error Cause by STRICT_TRANS_TABLES and NO_ZERO_DATE in sqlmode for mysql 5.7

disabled it and in this way all things work correctly .