PHPackages                             owlcorp/doctrine-microseconds-datetime - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. owlcorp/doctrine-microseconds-datetime

ActiveLibrary[Database &amp; ORM](/categories/database)

owlcorp/doctrine-microseconds-datetime
======================================

Adds support of microseconds time formats to Doctrine ORM &amp; Doctrine DBAL

v0.9.0(3y ago)710.8k↓39.3%6[1 issues](https://github.com/owlcorp/Doctrine-Microseconds-DateTime/issues)[2 PRs](https://github.com/owlcorp/Doctrine-Microseconds-DateTime/pulls)MITPHPPHP ^7.0|^8.0

Since Jan 10Pushed 3y ago3 watchersCompare

[ Source](https://github.com/owlcorp/Doctrine-Microseconds-DateTime)[ Packagist](https://packagist.org/packages/owlcorp/doctrine-microseconds-datetime)[ RSS](/packages/owlcorp-doctrine-microseconds-datetime/feed)WikiDiscussions main Synced yesterday

READMEChangelog (1)Dependencies (7)Versions (2)Used By (0)

Microseconds DateTime Support for Doctrine
==========================================

[](#microseconds-datetime-support-for-doctrine)

What is this about?
-------------------

[](#what-is-this-about)

This library has no fancy logo. It also lacks all cool badges, but what it has is a simple &amp; ready-to-use implementation of *mili-* and *microsecond* types for Doctrine ORM/DBAL.

Why?
----

[](#why)

Date and time is hard, databases are hard - a combination of the two is a nightmare. There's a [5+ years old issue](https://github.com/doctrine/dbal/issues/2873)describing the problem. To do it properly and across all platforms seems nearly impossible. However, it is possible to do it with a limited scope. This is why this package was created: [I](https://github.com/kiler129)[personally](https://github.com/doctrine/dbal/issues/2873#issuecomment-476294822) stepped into that issue many times over the years, and here came the time to stop copying &amp; pasting the same code.

How to use?
-----------

[](#how-to-use)

1. **Install with composer**: `composer require owlcorp/doctrine-microseconds-datetime` (it will work across PHP7.0-8+)
2. **Add DBAL types**

- If you're using Symfony, edit `config/packages/doctrine.yaml` and add: ```
    doctrine:
        dbal:
            types:
                time_micro: OwlCorp\DoctrineMicrotime\DBAL\Types\TimeMicroType
                time_immutable_micro: OwlCorp\DoctrineMicrotime\DBAL\Types\TimeImmutableMicroType
                datetime_micro: OwlCorp\DoctrineMicrotime\DBAL\Types\DateTimeMicroType
                datetime_immutable_micro: OwlCorp\DoctrineMicrotime\DBAL\Types\DateTimeImmutableMicroType
                datetimetz_micro: OwlCorp\DoctrineMicrotime\DBAL\Types\DateTimeTzMicroType
                datetimetz_immutable_micro: OwlCorp\DoctrineMicrotime\DBAL\Types\DateTimeTzImmutableMicroType
    ```
- If you're not using Symfony check official [Doctrine documentation](https://www.doctrine-project.org/projects/doctrine-orm/en/2.14/cookbook/custom-mapping-types.html).

3. **For ORM**, you can use it like so:

    ```
