Skip to content

brainlet-ali/laravel-convert-timezone

Repository files navigation

Latest Version on Packagist

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: [email protected]

License

The MIT License (MIT). Please see License File for more information.

About

No description, website, or topics provided.

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages