| Install | |
|---|---|
composer require webteractive/filament-browser-timezone |
|
| Latest Version: | 1.5.1 |
| PHP: | ^8.2 |
A Filament package that automatically detects the user's browser timezone and makes it available to Filament resources, forms, and widgets via session storage.
composer require webteractive/filament-browser-timezone
The package will be automatically discovered by Laravel.
The package automatically integrates with Filament and starts detecting timezone on every page load. No additional configuration required.
use Webteractive\FilamentBrowserTimezone\BrowserTimezone;
// Get the detected timezone
$timezone = BrowserTimezone::get();
// Check if timezone is available
if (BrowserTimezone::has()) {
$timezone = BrowserTimezone::get();
}
// Get with fallback
$timezone = BrowserTimezone::get('UTC');
use Webteractive\FilamentBrowserTimezone\BrowserTimezone;
class UserResource extends Resource
{
public function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('created_at')
->dateTime()
->timezone(BrowserTimezone::get())
->label('Created At'),
]);
}
}
use Webteractive\FilamentBrowserTimezone\BrowserTimezone;
class UserForm extends Form
{
public function form(Form $form): Form
{
return $form
->schema([
DateTimePicker::make('meeting_time')
->timezone(BrowserTimezone::get())
->label('Meeting Time'),
]);
}
}
use Webteractive\FilamentBrowserTimezone\BrowserTimezone;
class StatsWidget extends Widget
{
public function getColumns(): int
{
return 2;
}
protected function getTableQuery(): Builder
{
return User::query()
->where('created_at', '>=', now()->setTimezone(BrowserTimezone::get()));
}
}
Publish the configuration file:
php artisan vendor:publish --tag="filament-browser-timezone-config"
// config/filament-browser-timezone.php
return [
// Session key for storing timezone
'session_key' => env('BROWSER_TIMEZONE_SESSION_KEY', 'browser_timezone'),
// Fallback timezone if detection fails
'fallback_timezone' => env('BROWSER_TIMEZONE_FALLBACK', 'UTC'),
// Debug mode
'debug' => env('BROWSER_TIMEZONE_DEBUG', false),
];
BROWSER_TIMEZONE_SESSION_KEY=browser_timezone
BROWSER_TIMEZONE_FALLBACK=UTC
BROWSER_TIMEZONE_DEBUG=false
Intl.DateTimeFormat().resolvedOptions().timeZoneBrowserTimezone helper classThe package uses the modern Intl.DateTimeFormat API which is supported by:
For unsupported browsers, the package will use the configured fallback timezone.
| Package Version | Filament Version | Livewire Version | Laravel Version | PHP Version |
|---|---|---|---|---|
| 1.x | ^3.0||^4.0||^5.0 | ^3.0||^4.0 | ^10.0||^11.28||^12.0 | ^8.2 |
Note: Filament v3 and v4 use Livewire v3, while Filament v5 uses Livewire v4. This package supports both Livewire versions seamlessly.
This package includes custom AI guidelines for Laravel 12.x AI features. When using AI assistants with Laravel 12.x projects, the assistant will have access to comprehensive documentation about this package's usage patterns, best practices, and troubleshooting tips.
The AI guidelines are located in ai/custom-guidelines.md and provide:
composer test
The MIT License (MIT). Please see License File for more information.