bartoszbartniczak/doctrine-datetime-with-microseconds

Doctine extension that adds microseconds to \DateTime objects.

1.0.2 2021-10-01 08:35 UTC

This package is auto-updated.

Last update: 2024-10-29 05:28:37 UTC


README

Doctrine plugin to save DateTime objects with microseconds in database.

codecov

Installation

Via composer

composer require bartoszbartniczak/doctrine-datetime-with-microseconds

How does it work?

Standard Doctrine behavior

Doctrine saves \DateTime to the database correctly, but omits the microseconds, which are part of the \DateTime object.

Standard doctrine mapping:

1549735833745

The Doctrine ORM saves the date, but without microseconds:

1549735952539

In some systems this behavior is not expected. There are some situations where the microseconds are very important information, so they should be persisted.

Caution: Not every Database system supports Timestamps with microseconds.

How to use?

This library resolves problem of persisting microseconds with Doctrine.

Mapping

Instead of using standard Doctrine type datetime, you can use datetime_microseconds

example-mapping

After persisting object, you should have seen datetime value with microseconds saved.

Supported Relational Database Management Systems

  • PostgreSQL

Table of compatibility

*Microseconds are supported since version 5.6.4 [source1] [source2]

** Microseconds are supported since version 5.3 [source]

Other Relational Database Management Systems

If your RDBMS is not pointed on the list above, it does not mean that it will not work. It means that this library was not tested yet with that databse system. You can try and test it yourself, or even try contribute to this project.

  • Microsoft SQL Server - Not tested yet
  • Oracle database - Not tested yet
  • SQLite - Not tested yet