PHPackages                             timostamm/doctrine-fixed-timezone - 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. timostamm/doctrine-fixed-timezone

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

timostamm/doctrine-fixed-timezone
=================================

Normalize timezones in a Doctrine database.

v2.0.0(9mo ago)321.1k—5%3[3 issues](https://github.com/timostamm/doctrine-fixed-timezone/issues)MITPHPPHP ^8.0CI failing

Since Sep 3Pushed 9mo ago1 watchersCompare

[ Source](https://github.com/timostamm/doctrine-fixed-timezone)[ Packagist](https://packagist.org/packages/timostamm/doctrine-fixed-timezone)[ RSS](/packages/timostamm-doctrine-fixed-timezone/feed)WikiDiscussions master Synced 3w ago

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

Fixed timezone types for Doctrine
=================================

[](#fixed-timezone-types-for-doctrine)

[![build](https://github.com/timostamm/doctrine-fixed-timezone/workflows/CI/badge.svg)](https://github.com/timostamm/doctrine-fixed-timezone/actions?query=workflow:%22CI%22)[![Packagist PHP Version](https://camo.githubusercontent.com/3fe283d9d0c87cfe2435230295eb01e57066bfde942bce6ccfe31ed34e61e0b5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f74696d6f7374616d6d2f646f637472696e652d66697865642d74696d657a6f6e652f706870)](https://camo.githubusercontent.com/3fe283d9d0c87cfe2435230295eb01e57066bfde942bce6ccfe31ed34e61e0b5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f74696d6f7374616d6d2f646f637472696e652d66697865642d74696d657a6f6e652f706870)[![GitHub tag](https://camo.githubusercontent.com/8c8a32d7c73603bca68d6125484bdf5813dbe4fbec8a8274ef5f217a5b002b35/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7461672f74696d6f7374616d6d2f646f637472696e652d66697865642d74696d657a6f6e653f696e636c7564655f70726572656c65617365733d26736f72743d73656d76657226636f6c6f723d626c7565)](https://github.com/timostamm/doctrine-fixed-timezone/releases/)[![License](https://camo.githubusercontent.com/d6bc2b26794002c24d023acaab01b6dbb953c57ab9cb80ba5b8aa2f2bd5de99a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d626c7565)](#license)

### The problem

[](#the-problem)

If your application handles dates with different timezones, you have two options:

### 1) save the time zone of each date to the database

[](#1-save-the-time-zone-of-each-date-to-the-database)

If you need to know the timezone later on, this is the only option.

Unfortunately, this makes queries on dates practically impossible: `SELECT * FROM x WHERE x.date > CURRENT_TIMESTAMP()` will lead to unexpected results. CURRENT\_TIMESTAMP will use the current time of the database server, and your dates are interpreted in the wrong timezone.

### 2) Convert all dates saved in the database to one timezone

[](#2-convert-all-dates-saved-in-the-database-to-one-timezone)

If you convert all dates to the timezone of the database server, your queries will work as expected.

Unfortunately, Doctrine does not come with an option to do this conversion.

### Solution provided by this library

[](#solution-provided-by-this-library)

This library provides replacements for the DBAL types `datetime`, and `datetime_immutable`, which will automatically convert dates into the database timezone.

When reading a `datetime` or `datetime_immutable`, the timezone will **not be converted to the PHP timezone**. The dates will refer to the correct point in time, but have the database timezone.

### Regarding standalone date and time

[](#regarding-standalone-date-and-time)

A date without a time, or a time without a date both do not refer to an absolute point in time. Since PHP does not have types to represent stand-alone times or dates, developers use `DateTime`objects to represent those too, but their timezone should be ignored.

Therefore, it should be fine to use the standard `date` and `time`doctrine types.

### How to use

[](#how-to-use)

Symfony:

```
doctrine:
  dbal:
    # ...
    types:
      datetime: TS\DoctrineExtensions\DBAL\FixedDbTimezone\DateTimeType
      datetime_immutable: TS\DoctrineExtensions\DBAL\FixedDbTimezone\DateTimeImmutableType
```

To set the database timezone, define a constant `define('DATABASE_TIMEZONE', 'Europe/Berline');` or set an environment variable `DATABASE_TIMEZONE`.

Otherwise, the PHP timezone is used.

### Background

[](#background)

###  Health Score

42

—

FairBetter than 89% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 56.3% 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

Every ~367 days

Recently: every ~474 days

Total

8

Last Release

281d ago

Major Versions

v1.1.2 → v2.0.02025-09-15

PHP version history (3 changes)v1.0.2PHP ^7.1

v1.0.3PHP ^7.1|^8.0

v2.0.0PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/6364011a12f22cb5046056371bde6170218218c560eddfdc08b4644b7648af78?d=identicon)[timostamm](/maintainers/timostamm)

---

Top Contributors

[![timostamm](https://avatars.githubusercontent.com/u/4289451?v=4)](https://github.com/timostamm "timostamm (9 commits)")[![ducrot](https://avatars.githubusercontent.com/u/3525119?v=4)](https://github.com/ducrot "ducrot (6 commits)")[![naumso](https://avatars.githubusercontent.com/u/4818822?v=4)](https://github.com/naumso "naumso (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/timostamm-doctrine-fixed-timezone/health.svg)

```
[![Health](https://phpackages.com/badges/timostamm-doctrine-fixed-timezone/health.svg)](https://phpackages.com/packages/timostamm-doctrine-fixed-timezone)
```

###  Alternatives

[martin-georgiev/postgresql-for-doctrine

Extends Doctrine with native PostgreSQL support for arrays, JSONB, ranges, PostGIS geometries, text search, ltree, uuid, and 100+ PostgreSQL-specific functions.

4535.7M4](/packages/martin-georgiev-postgresql-for-doctrine)[flow-php/doctrine-dbal-bulk

Bulk inserts and updates for Doctrine DBAL

14361.1k3](/packages/flow-php-doctrine-dbal-bulk)[mahocommerce/maho

Free and open source ecommerce platform, created in 2024 on the M1 platform, PHP 8.3+

1384.8k32](/packages/mahocommerce-maho)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1615.6k12](/packages/2lenet-crudit-bundle)

PHPackages © 2026

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