I've created a table in Laravel with standard datetime columns:
Schema::create('lists', function (Blueprint $table) { $table->bigIncrements('id'); $table->string('name'); $table->string('ref'); $table->string('provider'); $table->timestamps(); $table->softDeletes(); $table->unique(['provider', 'ref']); }); When I try to do a simple record creation with Eloquent:
List::updateOrCreate([ 'provider' => 'test', 'ref' => 'S4d3g' ], [ 'name' => 'Plan' ]); I am given this message (which is a raw console output, so ignore the lack of quotes):
SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '2020-03-08 02:25:07' for column 'updated_at' at row 1 (SQL: insert into `lists` (`provider`, `ref`, `name`, `updated_at`, `created_at`) values (test, S4d3g, Plan, 2020-03-08 02:25:07, 2020-03-08 02:25:07)) Running the query manually on the database as raw SQL also doesn't work:
insert into `lists` (`provider`, `ref`, `name`, `updated_at`, `created_at`) values ('test', 'S4d3g', 'Plan', '2020-03-08 02:25:07', '2020-03-08 02:25:07') I'm using MySQL 5.7.
Inexplicably, if I change the date to anything other than 2 AM, it works:
insert into `lists` (`provider`, `ref`, `name`, `updated_at`, `created_at`) values ('test', 'S4d3g', 'Plan', '2020-03-08 01:25:07', '2020-03-08 01:25:07') insert into `lists` (`provider`, `ref`, `name`, `updated_at`, `created_at`) values ('test', 'S4d3g', 'Plan', '2020-03-08 03:25:07', '2020-03-08 03:25:07') What could be causing this bizarre MySQL level dislike of 2 AM on the timestamp?
DATETIMEwhich uses local timezone. (I preferTIMESTAMPfor that reason.) Also, think about what happens when DST ends - there are two 2am-s, but in SQL you cannot distinguish between 2A:00 and 2B:00, so be ready for that!