Skip to content
This repository has been archived by the owner on Mar 16, 2023. It is now read-only.

Network-Rail-Business-Systems/laravel-date-timezone

Repository files navigation

Output dates in a specific timezone while still maintaining UTC in the database

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.

Installation

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'))
];

Usage

protected $casts = [
    'created_at' => NetworkRailBusinessSystems\LaravelDateTimezone\Casts\DateTimezone::class;
]

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

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

About

A simple package that sets the output of dates to a specific timezone while still maintaining UTC in the database

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages