Environment:
PHP 8.1.6 (cli) (built: May 11 2022 08:55:59) (ZTS Visual C++ 2019 x64)
Copyright (c) The PHP Group
Zend Engine v4.1.6, Copyright (c) Zend Technologies
MySQL
Mysql Ver 8.2.0 for Win64 on x86_64 (MySQL Community Server – GPL)
Laravel
10.x
I have the two MySQL columns of created_at and updated_at in my table created by Laravel migration.
I am getting the following error when an attempt is made to insert data into MySQL:
“SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: ‘2024-08-19T19:24:44.000000Z’ for column ‘created_at’ at row 1”
I am using an insert staement to populate my table as follows:
$saveData = [];
foreach ($serious_dummy_ids as $id) {
$dummy_table = new Dummy_result();
$dummy_table->some_id = $dummy_id;
$dummy_table->created_at = Carbon::createFromFormat('Y-m-d H:i:s', Carbon::now());
$saveData[] = $dummy_table->attributesToArray();
}
$result = Filtering_result::insert($saveData);
I tried:
1. Carbon:now()
2. Carbon::createFromFormat('Y-m-d H:i:s', Carbon::now());
3. now()
2