PHPackages                             jord-jd/dates-timezone-conversion-trait - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. jord-jd/dates-timezone-conversion-trait

ActiveLibrary[Database &amp; ORM](/categories/database)

jord-jd/dates-timezone-conversion-trait
=======================================

Automatically convert an Eloquent model's dates to and from the current user's timezone

v3.0.0(3mo ago)2021LGPL-3.0-onlyPHP

Since Oct 10Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/Jord-JD/dates-timezone-conversion-trait)[ Packagist](https://packagist.org/packages/jord-jd/dates-timezone-conversion-trait)[ GitHub Sponsors](https://github.com/DivineOmega)[ RSS](/packages/jord-jd-dates-timezone-conversion-trait/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (2)Versions (7)Used By (0)

⏳🗺 Dates Timezone Conversion Trait
==================================

[](#-dates-timezone-conversion-trait)

This package provides a trait that automatically converts an Eloquent model's dates to and from the current user's timezone.

Installation
------------

[](#installation)

Dates Timezone Conversion Trait can be easily installed using Composer. Just run the following command from the root of your project.

```
composer require jord-jd/dates-timezone-conversion-trait

```

If you have never used the Composer dependency manager before, head to the [Composer website](https://getcomposer.org/) for more information on how to get started.

Usage
-----

[](#usage)

First, you must add a `timezone` field to your application's main `User`model and populate it with an appropriate timezone. Please see this [list of supported timezones](https://secure.php.net/manual/en/timezones.php).

Then, to benefit from this trait, simply `use` it within any Eloquent Model. An example of a `User` model with the trait being used is shown below.

```
