brainlet-ali / laravel-convert-timezone
A minimal package to convert any model datetime fields from UTC to desired timezone.
3.0
2024-03-16 09:10 UTC
Requires
- php: ^7.4|^8.0|^8.1
- doctrine/dbal: ^3.8.3
- illuminate/contracts: ^v9.0|^10|^v11.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.51
- laravel/pint: ^1.14
- orchestra/testbench: ^7.6|^8.22
- pestphp/pest: ^1.23.1
- pestphp/pest-plugin-laravel: ^1.4
- phpunit/phpunit: ^9.6.17|^10.0|^11.0
- vimeo/psalm: ^4.30
README
A minimal package to convert any model's datetime fields from UTC to desired timezone.
Installation
Laravel
You can install the package via composer:
composer require brainlet-ali/laravel-convert-timezone
You can publish the config file with:
php artisan vendor:publish --provider="Brainlet\LaravelConvertTimezone\LaravelConvertTimezoneServiceProvider" --tag="tz-config"
Usage
... use Brainlet\LaravelConvertTimezone\Traits\ConvertTZ; class MyModel extends Model { use ..., ConvertTZ; // ... } $myModel = MyModel::first(); $myModel->created_at; // (outputs converted to timezone as defined in config)
Limitations
- Only works with Eloquent models.
Security Vulnerabilities
If you found any security vulnerabilities please contact me at: ali@brainlet.co
License
The MIT License (MIT). Please see License File for more information.