bartoszbartniczak / doctrine-datetime-with-microseconds
Doctine extension that adds microseconds to \DateTime objects.
Installs: 62 039
Dependents: 0
Suggesters: 0
Security: 0
Stars: 7
Watchers: 2
Forks: 5
Open Issues: 4
Requires
- php: >=7.2
- doctrine/dbal: ^2.9
Requires (Dev)
- doctrine/orm: ^2.7
- phpstan/phpstan: ^0.12.5
- phpunit/phpunit: ^8.5
- symfony/var-dumper: ^5.0
- symplify/easy-coding-standard: ^7.2
- vimeo/psalm: ^3.8
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.
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:
The Doctrine ORM saves the date, but without microseconds:
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
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