The package provides a custom cast class that can be applied to your model attributes and will output dates in your desired timezone while maintaining the application's globally set timezone when persisting to the database.
You can install the package via composer:
composer require network-rail-business-systems/laravel-date-timezone
You can publish the config file with:
php artisan vendor:publish --tag="date-timezone-config"
This is the contents of the published config file:
return [
'output-timezone' => env('OUTPUT_TIMEZONE', config('app.timezone'))
];
protected $casts = [
'created_at' => NetworkRailBusinessSystems\LaravelDateTimezone\Casts\DateTimezone::class;
]
composer test
Please see CHANGELOG for more information on what has changed recently.
The MIT License (MIT). Please see License File for more information.