tapp/filament-timezone-field
Filament Timezone Field adds a timezone select component to Filament forms. Supports Filament 3/4/5, localized timezone labels, UTC or GMT display, and filtering options by country codes or region for cleaner, relevant timezone lists.
DateTimeZone and Symfony’s Intl for timezone handling, reducing custom logic overhead. The package abstracts complex timezone data (e.g., offsets, regions) into reusable components.TimezoneSelect, TimezoneColumn, TimezoneSelectFilter) are self-contained, enabling granular adoption (e.g., use only the form field without filters/columns).TimezoneSelect::make('timezone')->byCountry('US')->searchable();
'America/New_York'), compatible with any Laravel-supported DB (MySQL, PostgreSQL, SQLite).| Risk Area | Assessment | Mitigation Strategy |
|---|---|---|
| Filament Version Lock | Hard dependency on Filament 3/4/5. Downgrading risks breaking changes. | Pin version in composer.json (e.g., ^3.0) and test against Filament’s minor updates. |
| Browser Timezone Detection | getTimezoneFromBrowser() may fail in SPAs/auth pages (fixed in v3.0.13). |
Test in target environments; fallback to default timezone if JS detection fails. |
| Performance | Loading all timezones upfront (~400 options) may impact large forms. | Use byCountry()/byRegion() to filter options or lazy-load via AJAX. |
| Edge Cases | Empty values in TimezoneColumn (fixed in v3.0.5) or unsupported regions. |
Validate timezone strings in model rules (e.g., Rule::in(array_keys(DateTimeZone::listIdentifiers()))). |
Filament Version Strategy:
Timezone Data Scope:
Localization Needs:
Data Migration:
'UTC') or integers (e.g., offset hours)?Testing Coverage:
Carbon/DateTime for timezone conversions.| Step | Action | Tools/Dependencies |
|---|---|---|
| 1. Composer Installation | composer require tapp/filament-timezone-field:"^3.0" |
Composer |
| 2. Version Alignment | Ensure Filament is 3.x/4.x/5.x (check filament/filament in composer.json). |
composer why filament/filament |
| 3. Component Registration | Import and register components in Filament resources (forms/tables/filters). | PHP |
| 4. Data Validation | Add model rules to validate timezone strings (e.g., Rule::in(DateTimeZone::listIdentifiers())). |
Laravel Validation |
| 5. Testing | Test timezone rendering, filtering, and edge cases (e.g., invalid timezones). | PestPHP/PHPUnit |
| 6. Localization (Optional) | Configure Symfony Intl for non-English timezone names (e.g., config/app.php locales). |
Symfony Intl |
DateTimeZone::listIdentifiers() if performance is critical.byCountry('US')) before global adoption.TimezoneSelectFilter/TimezoneColumn.getTimezoneFromBrowser() in SPAs (fixed in v3.0.13).null in TimezoneColumn (fixed in v3.0.5).dd(DateTimeZone::listIdentifiers()) to inspect available timezones.byCountry()/byRegion() to filter options.'Asia/Tokyo').| Scenario | Impact | Mitigation |
|---|---|---|
| Invalid Timezone Submitted | Corrupt data in DB. | Validate with Rule::in(DateTimeZone::listIdentifiers()). |
| Symfony Intl Missing | Localized names fail. | Ensure symfony/intl is installed; fallback to English. |
| Filament Version Mismatch | Component breaks. | Pin package version in composer.json. |
| Browser Timezone Detection Fails | Default timezone used. | Add user override option or default to UTC. |
| Daylight Saving Transitions | Offset mismatches. | Use DateTimeZone methods to handle transitions dynamically. |
TimezoneSelect to test validation logic.How can I help you explore Laravel packages today?