1
0
mirror of synced 2025-02-09 00:39:25 +03:00

#1497 - Using a PHP code block to describe how a datetime+utc type can be set up

This commit is contained in:
Marco Pivetta 2015-12-11 18:48:23 +01:00
parent 5b22e59383
commit a130ff96ba

View File

@ -129,6 +129,20 @@ the UTC time at the time of the booking and the timezone the event happened in.
This database type makes sure that every DateTime instance is always saved in UTC, relative
to the current timezone that the passed DateTime instance has.
To actually use this new type instead of the default ``datetime`` type, you need to run following
code before bootstrapping the ORM:
.. code-block:: php
<?php
use Doctrine\DBAL\Types\Type;
use DoctrineExtensions\DBAL\Types\UTCDateTimeType;
Type::overrideType('datetime', UTCDateTimeType::class);
Type::overrideType('datetimetz', UTCDateTimeType::class);
To be able to transform these values
back into their real timezone you have to save the timezone in a separate field of the entity
requiring timezoned datetimes: