11# ⏳🗺 Dates Timezone Conversion Trait
22
3- This package provides a trait that automatically converts an Eloquent
3+ This package provides a trait that automatically converts an Eloquent
44model's dates to and from the current user's timezone.
55
66## Installation
77
8- Dates Timezone Conversion Trait can be easily installed using Composer.
8+ Dates Timezone Conversion Trait can be easily installed using Composer.
99Just run the following command from the root of your project.
1010
1111```
1212composer require divineomega/dates-timezone-conversion-trait
1313```
1414
15- If you have never used the Composer dependency manager before, head
16- to the [ Composer website] ( https://getcomposer.org/ ) for more
15+ If you have never used the Composer dependency manager before, head
16+ to the [ Composer website] ( https://getcomposer.org/ ) for more
1717information on how to get started.
1818
1919## Usage
2020
2121First, you must add a ` timezone ` field to your application's main ` User `
22- model and populate it will an appropriate timezone. Please see this [ list
22+ model and populate it with an appropriate timezone. Please see this [ list
2323 of supported timezones] ( https://secure.php.net/manual/en/timezones.php ) .
2424
25- Then, to benefit from this trait, simply ` use ` it within any Eloquent Model.
25+ Then, to benefit from this trait, simply ` use ` it within any Eloquent Model.
2626An example of a ` User ` model with the trait being used is shown below.
2727
2828``` php
@@ -37,24 +37,24 @@ use Illuminate\Foundation\Auth\User as Authenticatable;
3737class User extends Authenticatable
3838{
3939 use Notifiable, DatesTimezoneConversion;
40-
40+
4141 protected $dates = [
4242 'last_logged_in_at',
4343 'created_at',
4444 'updated_at'
4545 ];
46-
46+
4747 /* snipped */
4848}
4949```
5050
51- After using the trait, the following transformation will automatically be
52- applied to any attributes defined in the model's ` $dates ` array, if a
51+ After using the trait, the following transformation will automatically be
52+ applied to any attributes defined in the model's ` $dates ` array, if a
5353user is currently logged in.
5454
5555* When reading an attribute (e.g. ` $user->last_logged_in_at ` ), the datetime
5656object will automatically be converted to the user's timezone.
5757
5858* When writing to an attribute (e.g. ` $user->last_logged_in_at ` ), the datetime
59- will automatically be converted to the Laravel application's timezone (as
59+ will automatically be converted to the Laravel application's timezone (as
6060defined in the ` config/app.php ` file).
0 commit comments