I got a problem like this :
StartOn: "2022-12-08"
But I choose a calendar in primevue is : 2022-12-09
When I choose a date in calendar. It automatically goes back 1 day.
This is my code in vue:
<Calendar
inputId="time24"
v-model="this.collectionItems.StartOn"
:showTime="false"
:showSeconds="true"
:date-format='yy-mm-dd'
/>
This is my code in Laravel Backend
public function create(Request $req)
{
try {
$collection = new Collection();
$collection->NameCollection = $req->input('NameCollection');
$collection->Description = $req->input('Description');
$collection->LogoImagePath = $req->input('LogoImagePath');
$collection->WallPaperPath = $req->input('WallPaperPath');
$collection->StartOn= Carbon::parse($req->StartOn)->format('Y-m-d');
$collection->EndOn = $req->input('EndOn');
$collection->CoverImagePath = $req->input('CoverImagePath');
$collection->save();
return $collection;
} catch (Throwable $e) {
return $e->getMessage();
}
}
What is the problem ? How do I fix it ? I want to result is when I choose 2022-12-09, I had a result is 2022-12-09