F
Filament13mo ago
Oddman

Datepicker timezones - I don't get this

I'm wanting to have published dates and times in the user's local timezone. This is managed by their browser/OS, and most datepickers will use this to convert to/from the provided date and time (UTC). How can I do this using Filament's datepicker? The documentation seems to imply that you have to provide the user's timezone from the server, which needs to be saved for the user, and is also erroneous (what happens if a user is publishing from a different timezone than normal?)
7 Replies
HerrChris
HerrChris13mo ago
In most apps I've worked in the user model has a timezone setting configured. Then from UTC it will change to the user's specified local time. I always stored the datetimes with the unix epoch So the example DateTimePicker::make('published_at')->timezone('America/New_York') - would just pull the timezone from the user model
awcodes
awcodes13mo ago
At the db level it should always be stored as utc and converted on output.
Oddman
OddmanOP13mo ago
For the dates themselves, yes - but for the timezones, I don't have user timezone data (and like I said, most datetime pickers allow in the client to handle this automatically), so curious why it requires a user's timezone here. I have authors all over the world, some travel - having them reset their timezone each time is a bad user experience.
awcodes
awcodes13mo ago
If you’re using the native datetime field it should handle it at the browser level. Iirc. Would have to check but I think it uses datetime-local if it’s the native implementation. So not using ->native(false) on the field.
Oddman
OddmanOP13mo ago
I'll double-check that.
Saifallak
Saifallak9mo ago
did it work ?
Oddman
OddmanOP9mo ago
No
Want results from more Discord servers?
Add your server