PHPackages                             soomedia/doctrine-utcdatetime - 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. soomedia/doctrine-utcdatetime

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

soomedia/doctrine-utcdatetime
=============================

Doctrine2 DateTimeType that will always store your DateTime in the UTC timezone

37.4k2[1 issues](https://github.com/SooMedia/doctrine-utcdatetime/issues)PHP

Since Mar 30Pushed 10y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Doctrine UTCDateTimeType
========================

[](#doctrine-utcdatetimetype)

Doctrine2 DateTimeType that will always store your DateTime in the UTC timezone.

All the code in this library was found in [DoctrineExtensions' documentation](https://github.com/Atlantic18/DoctrineExtensions/blob/e94b30342810d028559dade3e4bac13520e93ba1/doc/timestampable.md#creating-a-utc-datetime-type-that-stores-your-datetimes-in-utc). I take no credits for this code, I just simply bundled it in a nice and easy to use package.

Using the UTCDateTimeType
-------------------------

[](#using-the-utcdatetimetype)

### Add the library

[](#add-the-library)

Add the library in your project with Composer:

`$ composer require soomedia/doctrine-utcdatetime`

### Override the default datetime type

[](#override-the-default-datetime-type)

Simply copied from DoctrineExtensions' documentation:

We simply have to register and override the **datetime** type. **WARNING:** this will override the **datetime** type for all your entities and for all entities in external bundles or extensions, so if you have some entities that require the standard **datetime** type from Doctrine, you must modify the above type and use a different name (such as **utcdatetime**). Additionally, if you use DoctrineExtensions, you'll need to modify Timestampable so that it includes **utcdatetime** as a valid type.

In Symfony2 you can do this like so:

```
doctrine:
    dbal:
        types:
            datetime: SooMedia\Doctrine\DBAL\Types\UTCDateTimeType
```

In Zend Framework 2 you have to add the following to your `module.config.php`:

```
