Try
'date' => $faker->dateTimeBetween('-6 months', 'now')->format('Y-m-d H:i:s'),
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I'm writing seeders, and I have one model with $timestamps = false.
On that model I have a custom timestamp field, and I cast it using the $dates = [] property.
Now in my seeder I have:
'date' => $faker->dateTimeBetween('-6 months', 'now')->format('Y-m-d'),
But I always get an error:
Invalid datetime format: 1292 Incorrect datetime value: '2020-03-07T08:59:07.000000Z' for column 'date' at row 1
Tried a shitload of things, but nothing works, only when I comment out the
protected $dates = [
'date',
];
the timestamp field saves...
What am I doing wrong? Laravel's documentation says that $dates can be passed in various formats, such as a simple date string like 2019-12-23, but it does not work.
Please or to participate in this conversation.