You could set the field as a date in your model, then it should convert that string to a valid db date.
https://laravel.com/docs/5.3/eloquent-mutators#date-mutators
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Trying to seed some data for some settings for an application, and some of the settings have a date column, in the standard 2000-01-01 format.
How does one go about seeding this?
Setting::create([
'name' => 'Start Date',
'date' => '1900-01-01'
]);
I don't want a random date, I want it set to a specific date.
Throws the error: [InvalidArgumentException] The separation symbol could not be found Unexpected data found. Trailing data
I did at one point try adding this to the top of the DatabaseSeeder.php file:
use Carbon\Carbon;
and then using...
Setting::create([
'name' => 'Start Date',
'date' => Carbon::create('2000', '01', '01')
]);
but received the same error.
What ended up working was changing it from Setting::create to..
DB::table('settings')->insert([
'name' => 'Start Date',
'date' => Carbon::create('2000', '01', '01')
]);
Please or to participate in this conversation.