2017 © Pedro Peláez
 

library doctrine-utcdatetime

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

image

soomedia/doctrine-utcdatetime

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

  • Wednesday, March 30, 2016
  • by willemo
  • Repository
  • 1 Watchers
  • 2 Stars
  • 1,223 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 1 Open issues
  • 1 Versions
  • 26 % Grown

The README.md

Doctrine UTCDateTimeType

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)

Using the UTCDateTimeType

Add the library

Add the library in your project with Composer:, (*3)

$ composer require soomedia/doctrine-utcdatetime, (*4)

Override the default datetime type

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 ), );

Credits

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)

The Versions

30/03 2016

dev-master

9999999-dev

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

  Sources   Download

MIT

The Requires

 

by Willem Oostendorp

doctrine2 datetime utc