Skip to content

simPod/doctrine-utcdatetime

Repository files navigation

Doctrine UTCDateTimeType

GitHub Actions Code Coverage Downloads Packagist

Contains DateTime and DateTimeImmutable Doctrine DBAL types that store datetimes in UTC timezone (TIMESTAMP type in postgres).

For more detailed explanation see Doctrine ORM docs and this comment.

For more info about usage in Doctrine ORM see Doctrine documentation. The code is mostly copied from there.

Using the UTCDateTimeType

Installation

composer require simpod/doctrine-utcdatetime

Overriding default types in Symfony

Simply copied from DoctrineExtensions' documentation:

doctrine:
    dbal:
        types:
            datetime: SimPod\DoctrineUtcDateTime\UTCDateTimeType
            datetimetz: SimPod\DoctrineUtcDateTime\UTCDateTimeType
            datetime_immutable: SimPod\DoctrineUtcDateTime\UTCDateTimeImmutableType
            datetimetz_immutable: SimPod\DoctrineUtcDateTime\UTCDateTimeImmutableType