Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/simpod/doctrine-utcdatetime
UTC DateTime types for Doctrine DBAL and ORM
https://github.com/simpod/doctrine-utcdatetime
datetime doctrine doctrine-dbal doctrine-orm immutable orm php utcdatetime
Last synced: 2 months ago
JSON representation
UTC DateTime types for Doctrine DBAL and ORM
- Host: GitHub
- URL: https://github.com/simpod/doctrine-utcdatetime
- Owner: simPod
- License: mit
- Created: 2018-10-09T11:07:04.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-09-27T09:17:10.000Z (3 months ago)
- Last Synced: 2024-10-12T13:27:59.766Z (3 months ago)
- Topics: datetime, doctrine, doctrine-dbal, doctrine-orm, immutable, orm, php, utcdatetime
- Language: PHP
- Homepage:
- Size: 66.4 KB
- Stars: 8
- Watchers: 4
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
# Doctrine UTCDateTimeType
[![GitHub Actions][GA Image]][GA Link]
[![Code Coverage][Coverage Image]][CodeCov Link]
[![Downloads][Downloads Image]][Packagist Link]
[![Packagist][Packagist Image]][Packagist Link][GA Image]: https://github.com/simPod/doctrine-utcdatetime/workflows/CI/badge.svg
[GA Link]: https://github.com/simPod/doctrine-utcdatetime/actions?query=workflow%3A%22CI%22+branch%3Amaster
[Coverage Image]: https://codecov.io/gh/simPod/doctrine-utcdatetime/branch/master/graph/badge.svg
[CodeCov Link]: https://codecov.io/gh/simPod/doctrine-utcdatetime/branch/master
[Downloads Image]: https://poser.pugx.org/simPod/doctrine-utcdatetime/d/total.svg
[Packagist Image]: https://poser.pugx.org/simPod/doctrine-utcdatetime/v/stable.svg
[Packagist Link]: https://packagist.org/packages/simPod/doctrine-utcdatetime
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](https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/cookbook/working-with-datetime.html#handling-different-timezones-with-the-datetime-type) and [this comment](https://github.com/simPod/doctrine-utcdatetime/issues/6#issuecomment-722343092).
For more info about usage in Doctrine ORM see [Doctrine documentation](https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/cookbook/working-with-datetime.html). The code is mostly copied from there.
## Using the UTCDateTimeType
### Installation
```sh
composer require simpod/doctrine-utcdatetime
```### Overriding default types in Symfony
Simply copied from DoctrineExtensions' documentation:
``` yaml
doctrine:
dbal:
types:
datetime: SimPod\DoctrineUtcDateTime\UTCDateTimeType
datetimetz: SimPod\DoctrineUtcDateTime\UTCDateTimeType
datetime_immutable: SimPod\DoctrineUtcDateTime\UTCDateTimeImmutableType
datetimetz_immutable: SimPod\DoctrineUtcDateTime\UTCDateTimeImmutableType
```