Level 102
Cast it to a date (carbon) object in the model
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
First, I am just trying to show an input with date

<input type="date" wire:model="sprintStartDate"/>
I set the variable sprintStartDate with this
$this->sprintStartDate = $this->sprint->date_start->format('Y-m-d');
I get this error Call to a member function format() on string
https://flareapp.io/share/o7A48zEP#F61
When I dd($this->sprint->date_start); , I get ^ "2022-06-24 18:09:17"
In the migration date_start is set too
$table->dateTime('date_start')->nullable();
in the factory I seed it with
date_start' => $this->faker->dateTimeBetween('-5 days', '-2 days'),
My Confusion
When I use $sprint->created_at it does work properly, but isn't created_at and updated_at also dateTimes? How come it won't work when I create my own column with the type of dateTime?
Cast it to a date (carbon) object in the model
Please or to participate in this conversation.