PHPackages                             gnireeg/laravel-timezoned - 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. gnireeg/laravel-timezoned

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

gnireeg/laravel-timezoned
=========================

A lightweight Laravel package that provides a trait to automatically convert all date attributes of an Eloquent model from the database timezone to the user's timezone - and convert incoming user-provided dates back to the database timezone as well.

1.0.0(5mo ago)02MITPHPPHP &gt;=8.1CI passing

Since Nov 23Pushed 5mo agoCompare

[ Source](https://github.com/gnireeG/laravel-timezoned)[ Packagist](https://packagist.org/packages/gnireeg/laravel-timezoned)[ RSS](/packages/gnireeg-laravel-timezoned/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (5)Versions (2)Used By (0)

Laravel Timezoned
=================

[](#laravel-timezoned)

A lightweight Laravel package that automatically converts Eloquent model date attributes between the database timezone and the user's timezone.

- **DB → User timezone** when reading attributes
- **User → DB timezone** when writing attributes

This ensures consistent and intuitive date handling across different user timezones.

---

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

[](#installation)

```
composer require gnireeg/laravel-timezoned
```

Optionally publish the config:

```
php artisan vendor:publish --tag=config
```

---

Usage
-----

[](#usage)

```
use Gnireeg\LaravelTimezoned\HasTimezoneConversion;

class Event extends Model
{
    use HasTimezoneConversion;

    protected array $timezonedAttributes = ['starts_at', 'ends_at'];
}
```

### Reading Attributes

[](#reading-attributes)

```
// Automatically converted to user's timezone
$event->starts_at; // Returns Carbon in user's timezone
```

### Writing Attributes

[](#writing-attributes)

```
// Automatically converted to database timezone
$event->starts_at = '2025-03-10 15:00';
$event->save();
```

### Raw Attribute Access

[](#raw-attribute-access)

```
// Get the value in database timezone (bypass conversion)
$event->getRawAttribute('starts_at');
```

---

Configuration
-------------

[](#configuration)

The package config (`config/timezoned.php`) has two options:

### Timezone Resolver

[](#timezone-resolver)

Determines the user's timezone. Receives the model instance as a parameter.

```
// Default: uses authenticated user's timezone
'timezone_resolver' => function ($model) {
    return auth()->user()?->timezone ?? 'UTC';
},

// Or use session
'timezone_resolver' => fn() => session('timezone', 'UTC'),

// Or request header
'timezone_resolver' => fn() => request()->header('X-Timezone', 'UTC'),
```

### Database Timezone

[](#database-timezone)

The timezone your database stores dates in. Set to `null` to use `config('app.timezone')`.

```
'database_timezone' => null, // Uses app.timezone
'database_timezone' => 'UTC', // Explicit UTC
```

---

How It Works
------------

[](#how-it-works)

The trait overrides two Eloquent methods:

- `getAttribute()` - converts dates from database timezone to user's timezone
- `setAttribute()` - converts dates from user's timezone to database timezone

Both `Carbon` and `CarbonImmutable` instances are supported.

---

Requirements
------------

[](#requirements)

- PHP &gt;= 8.1
- Laravel 10, 11, or 12
- Carbon &gt;= 2

---

Testing
-------

[](#testing)

```
composer test
```

---

License
-------

[](#license)

MIT

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance70

Regular maintenance activity

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

171d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b1167ca8a2599768a09042dbb86286188001653ef5c19c52598d00fc507c1b68?d=identicon)[gnireeG](/maintainers/gnireeG)

---

Top Contributors

[![gnireeG](https://avatars.githubusercontent.com/u/48487313?v=4)](https://github.com/gnireeG "gnireeG (5 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/gnireeg-laravel-timezoned/health.svg)

```
[![Health](https://phpackages.com/badges/gnireeg-laravel-timezoned/health.svg)](https://phpackages.com/packages/gnireeg-laravel-timezoned)
```

###  Alternatives

[cybercog/laravel-love

Make Laravel Eloquent models reactable with any type of emotions in a minutes!

1.2k302.7k1](/packages/cybercog-laravel-love)[cviebrock/eloquent-taggable

Easy ability to tag your Eloquent models in Laravel.

567694.8k3](/packages/cviebrock-eloquent-taggable)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

423715.4k1](/packages/clickbar-laravel-magellan)[genealabs/laravel-pivot-events

This package introduces new eloquent events for sync(), attach(), detach() or updateExistingPivot() methods on BelongsToMany relation.

1404.9M8](/packages/genealabs-laravel-pivot-events)[jerome/filterable

Streamline dynamic Eloquent query filtering with seamless API request integration and advanced caching strategies.

19226.1k](/packages/jerome-filterable)[reedware/laravel-relation-joins

Adds the ability to join on a relationship by name.

2121.2M13](/packages/reedware-laravel-relation-joins)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
