@ignium can you show the Model where you are saving these values?
Livewire assuming date inputs are in UTC
I'm struggling to get a javascript date picker (pikaday) working using the example on the Livewire Site after some tweaking I finally got it working.
The issue is I have two inputs on the page to select a start and end date, when changing an input and the model is updated, it seems livewire is making the assumption that the times are being sent in UTC so it adds the offset to both model attributes. This is a problem because when it initially hydrates the model, it's already adding the offset, and if for some reason a user changes the end date, 3 times, 28 hours will have been added to the start time (changing it to a day later) without firing an input event so the in the input looks like it has not changed.
I was able to prevent this problem from happening by reverting the timezone setting in /config/app.php back to 'timezone' => 'UTC'. Obviously this isn't what I want to do, as all of stored timestamps are now off by 7 or 8 hours.
Here are the results of a dd() in the updatedModelEndDate($value) hook:
"Sat Aug 01 2020 14:00:00 GMT-0700" //$this->model->start_date->toString()
"Tue Mar 23 2021 23:59:59 GMT-0700" //$this->model->end_date->toString()
"Tue Mar 23 2021 07:00:00 GMT+0000" //Carbon::parse($value)->toString()
"2021-03-23T07:00:00.000Z" //$value
I'll be the first to admit that time has always been a pain point for me in programming, but I think there must be a config issue somewhere that I'm missing.
Any help would be much appreciated as I've been ripping my hair out on this one all weekend.
PS: As I said, I'm pretty sure this is a configuration issue, so I haven't posted any code, but can do that if it will help find a solution.
@ignium including the one that is initialize like protected $dates in UniqueTimePeriod class
Please or to participate in this conversation.