A minimal package to convert any model's datetime fields from UTC to desired timezone.
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"
...
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)
- Only works with Eloquent models.
If you found any security vulnerabilities please contact me at: ali@brainlet.co
The MIT License (MIT). Please see License File for more information.