I figured it out all I needed to do was put my date inside the new Date()
mounted() {
this.selectedValue = this.event.dates.map(a => new Date(a.date));
},
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi, I have a dates question. I am using v-calendar to do my dates. When I select on a number of dates it uses new Date to generate an array of dates in Vue
data() {
return {
selectedValue: new Date(),
}
},
I send this to my laravel controller and store it in my mysql database like so
foreach( $request->dates as $date) {
$newDate = Carbon::parse($date)->format('Y-m-d H:i:s');
Date::create([
'date' => $newDate,
'event_id' => $event->id
]);
}
My issue comes about when I head back to the input calendar page. I am mounting my dates like so
mounted() {
this.selectedValue = this.event.dates.map(a => a.date);
},
The selectedValue does create the array but INSTEAD of this:
Wed Oct 16 2019 00:00:00 GMT-0700 (Pacific Daylight Time)
I see this
"2019-10-16 07:00:00"
Im guessing this is an issue of how I am storing in the database but if I try to directly store the dates without parsing them through Carbon I get an error
Invalid datetime format: 1292 Incorrect datetime value: '2019-10-09T07:00:00.000Z'
I am using $table->dateTime('date'); for my mysql. Has anyone dealt with this before?
I figured it out all I needed to do was put my date inside the new Date()
mounted() {
this.selectedValue = this.event.dates.map(a => new Date(a.date));
},
Please or to participate in this conversation.