{"id":15985006,"url":"https://github.com/divineomega/dates-timezone-conversion-trait","last_synced_at":"2025-03-17T15:32:12.720Z","repository":{"id":56969659,"uuid":"152334991","full_name":"DivineOmega/dates-timezone-conversion-trait","owner":"DivineOmega","description":"⏳🗺 Automatically convert an Eloquent model's dates to and from the current user's timezone","archived":false,"fork":false,"pushed_at":"2019-04-11T07:37:34.000Z","size":10,"stargazers_count":22,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-28T01:18:08.253Z","etag":null,"topics":["eloquent","laravel","timezone","timezone-conversion","trait"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DivineOmega.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-09T23:32:34.000Z","updated_at":"2025-01-22T12:51:03.000Z","dependencies_parsed_at":"2022-08-21T06:40:21.549Z","dependency_job_id":null,"html_url":"https://github.com/DivineOmega/dates-timezone-conversion-trait","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DivineOmega%2Fdates-timezone-conversion-trait","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DivineOmega%2Fdates-timezone-conversion-trait/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DivineOmega%2Fdates-timezone-conversion-trait/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DivineOmega%2Fdates-timezone-conversion-trait/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DivineOmega","download_url":"https://codeload.github.com/DivineOmega/dates-timezone-conversion-trait/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243869400,"owners_count":20361008,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["eloquent","laravel","timezone","timezone-conversion","trait"],"created_at":"2024-10-08T02:11:54.320Z","updated_at":"2025-03-17T15:32:12.398Z","avatar_url":"https://github.com/DivineOmega.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ⏳🗺 Dates Timezone Conversion Trait\n\nThis package provides a trait that automatically converts an Eloquent\nmodel's dates to and from the current user's timezone.\n\n## Installation\n\nDates Timezone Conversion Trait can be easily installed using Composer.\nJust run the following command from the root of your project.\n\n```\ncomposer require divineomega/dates-timezone-conversion-trait\n```\n\nIf you have never used the Composer dependency manager before, head\nto the [Composer website](https://getcomposer.org/) for more\ninformation on how to get started.\n\n## Usage\n\nFirst, you must add a `timezone` field to your application's main `User`\nmodel and populate it with an appropriate timezone. Please see this [list\n of supported timezones](https://secure.php.net/manual/en/timezones.php).\n\nThen, to benefit from this trait, simply `use` it within any Eloquent Model.\nAn example of a `User` model with the trait being used is shown below.\n\n```php\n\u003c?php\n\nnamespace App\\Models;\n\nuse DivineOmega\\DatesTimezoneConversion\\Traits\\DatesTimezoneConversion;\nuse Illuminate\\Notifications\\Notifiable;\nuse Illuminate\\Foundation\\Auth\\User as Authenticatable;\n\nclass User extends Authenticatable\n{\n    use Notifiable, DatesTimezoneConversion;\n\n    protected $dates = [\n        'last_logged_in_at',\n        'created_at',\n        'updated_at'\n    ];\n\n    /* snipped */\n}\n```\n\nAfter using the trait, the following transformation will automatically be\napplied to any attributes defined in the model's `$dates` array, if a\nuser is currently logged in.\n\n* When reading an attribute (e.g. `$user-\u003elast_logged_in_at`), the datetime\nobject will automatically be converted to the user's timezone.\n\n* When writing to an attribute (e.g. `$user-\u003elast_logged_in_at`), the datetime\nwill automatically be converted to the Laravel application's timezone (as\ndefined in the `config/app.php` file).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdivineomega%2Fdates-timezone-conversion-trait","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdivineomega%2Fdates-timezone-conversion-trait","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdivineomega%2Fdates-timezone-conversion-trait/lists"}