Doctrine DBAL UTC DateTime
UTC DateTime type for Doctrine DBAL., (*1)
, (*2)
, (*3)
, (*4)
Why this DBAL Type?
This special type allow you to be sure to always save any DateTime to the UTC format., (*5)
The goal is to get rid of the quite hazardous timezone management of many database vendors., (*6)
For more information, please read the official Doctrine wiki page, where this class come from., (*7)
Setup
First of all, you need to require this library through composer:, (*8)
``` bash
composer require sllh/doctrine-dbal-utc-datetime, (*9)
Then, replace the default `datetime` and `datetimetz` DBAL types:
```php
use Doctrine\DBAL\Types\Type;
use SLLH\Doctrine\DBAL\Types\UTCDateTimeType;
Type::overrideType('datetime', UTCDateTimeType::class);
Type::overrideType('datetimetz', UTCDateTimeType::class);
If you are using Symfony, you can override the type trough the config.yml file:, (*10)
doctrine:
dbal:
types:
datetime: SLLH\Doctrine\DBAL\Types\UTCDateTimeType
datetimetz: SLLH\Doctrine\DBAL\Types\UTCDateTimeType
And voilĂ ! You are good to go. Happy coding!, (*11)
License
This bundle is under the MIT license. See the complete license on the LICENSE file., (*12)