© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago
KeyMe

DateTimePicker timezone issue

In an action, I have checkboxes where upon checking/un-checking, the corresponding datetimepicker field is set to now()->format('Y-m-d H:i:s') otherwise null. Casted the db fields to 'datetime'. Applied the timezone() method to use current user's timezone.
Weird thing is, fields that are saved before and after applying timezone() are stored in database differently, the prior, stored in UTC & displayed as user timezone, the latter, stored in user's tz & displayed as UTC.
On top of that, for fields stored as UTC in db, when i uncheck/re-check to fill new timestamp, it displays as UTC, is that normal?
Below is the form:

Checkbox::make($checkbox)
                ->reactive()
                ->dehydrated(false)
                ->afterStateUpdated(fn ($get, $set) => $get($checkbox) ?
                    $set($col, now()->format('Y-m-d H:i:s')) : $set($col, null)
                )
                ->formatStateUsing(function ($get) use ($col) {
                    return $get($col) ? true : false;
                }),
            DateTimePicker::make($col)
                ->timezone('Asia/Kuala_Lumpur')
                ->native(false)
                ->visible(function ($get, Model $record) use ($checkbox, $col) { 
                    return $get($checkbox) || isset($record->fulfillment->$col);
                    }
                )
                ->hiddenLabel(),
Checkbox::make($checkbox)
                ->reactive()
                ->dehydrated(false)
                ->afterStateUpdated(fn ($get, $set) => $get($checkbox) ?
                    $set($col, now()->format('Y-m-d H:i:s')) : $set($col, null)
                )
                ->formatStateUsing(function ($get) use ($col) {
                    return $get($col) ? true : false;
                }),
            DateTimePicker::make($col)
                ->timezone('Asia/Kuala_Lumpur')
                ->native(false)
                ->visible(function ($get, Model $record) use ($checkbox, $col) { 
                    return $get($checkbox) || isset($record->fulfillment->$col);
                    }
                )
                ->hiddenLabel(),
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

DateTimePicker Issue
FilamentFFilament / ❓┊help
2y ago
DateTimePicker steps issue
FilamentFFilament / ❓┊help
3mo ago
DateTimePicker
FilamentFFilament / ❓┊help
2y ago
Native DateTimePicker
FilamentFFilament / ❓┊help
2y ago