dev-master
9999999-devDoctrine2 DateTimeType that will always store your DateTime in the UTC timezone
MIT
The Requires
- php >=5.3.2
- doctrine/orm 2.*
by Willem Oostendorp
doctrine2 datetime utc
Doctrine2 DateTimeType that will always store your DateTime in the UTC timezone
Doctrine2 DateTimeType that will always store your DateTime in the UTC timezone., (*1)
All the code in this library was found in DoctrineExtensions' documentation. I take no credits for this code, I just simply bundled it in a nice and easy to use package., (*2)
Add the library in your project with Composer:, (*3)
$ composer require soomedia/doctrine-utcdatetime
, (*4)
Simply copied from DoctrineExtensions' documentation:, (*5)
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., (*6)
In Symfony2 you can do this like so:, (*7)
``` yaml doctrine: dbal: types: datetime: SooMedia\Doctrine\DBAL\Types\UTCDateTimeType, (*8)
In Zend Framework 2 you have to add the following to your `module.config.php`: ``` php <?php return array( // other module config here 'doctrine' => array( 'configuration' => array( 'orm_default' => array( // use the name of your default configuration/connection 'types' => array( 'datetime' => 'SooMedia\Doctrine\DBAL\Types\UTCDateTimeType', ), ), ), // other configuration here, like the driver config ), );
As I said: all credits for this piece of brilliant code goes to DoctrineExtensions. DoctrineExtensions adds a whole bunch of extra goodies to Doctrine, so I can really recommend using it!, (*9)
Doctrine2 DateTimeType that will always store your DateTime in the UTC timezone
MIT
doctrine2 datetime utc