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

This package is auto-updated.

Last update: 2024-10-16 10:33:55 UTC


README

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: ali@brainlet.co

License

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