PHPackages                             bartoszbartniczak/doctrine-datetime-with-microseconds - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. bartoszbartniczak/doctrine-datetime-with-microseconds

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

bartoszbartniczak/doctrine-datetime-with-microseconds
=====================================================

Doctine extension that adds microseconds to \\DateTime objects.

1.0.2(4y ago)774.3k↓45.2%6[2 issues](https://github.com/BartoszBartniczak/Doctrine-DateTime-With-Microseconds/issues)[2 PRs](https://github.com/BartoszBartniczak/Doctrine-DateTime-With-Microseconds/pulls)Apache-2.0PHPPHP &gt;=7.2

Since Feb 11Pushed 3y ago1 watchersCompare

[ Source](https://github.com/BartoszBartniczak/Doctrine-DateTime-With-Microseconds)[ Packagist](https://packagist.org/packages/bartoszbartniczak/doctrine-datetime-with-microseconds)[ RSS](/packages/bartoszbartniczak-doctrine-datetime-with-microseconds/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (7)Versions (13)Used By (0)

Doctrine DateTime With Microseconds
===================================

[](#doctrine-datetime-with-microseconds)

Doctrine plugin to save DateTime objects with microseconds in database.
-----------------------------------------------------------------------

[](#doctrine-plugin-to-save-datetime-objects-with-microseconds-in-database)

[![codecov](https://camo.githubusercontent.com/543d5f977838a3209610e8e08d8b5f9bc9cbe790b93a04f10e385a19b942dac3/68747470733a2f2f636f6465636f762e696f2f67682f426172746f737a426172746e69637a616b2f446f637472696e652d4461746554696d652d576974682d4d6963726f7365636f6e64732f6272616e63682f6d61737465722f67726170682f62616467652e7376673f746f6b656e3d5745595a5657414a4551)](https://codecov.io/gh/BartoszBartniczak/Doctrine-DateTime-With-Microseconds)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

[](#)

Installation
------------

[](#installation)

Via composer

`composer require bartoszbartniczak/doctrine-datetime-with-microseconds`

How does it work?
-----------------

[](#how-does-it-work)

### Standard Doctrine behavior

[](#standard-doctrine-behavior)

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

### Standard doctrine mapping:

[](#standard-doctrine-mapping)

[![1549735833745](docs/doctrine-standard-mapping.png)](docs/doctrine-standard-mapping.png)

The Doctrine ORM saves the date, but without microseconds:

[![1549735952539](docs/doctrine-standard-result.png)](docs/doctrine-standard-result.png)

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?

[](#how-to-use)

This library resolves problem of persisting microseconds with Doctrine.

### Mapping

[](#mapping)

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

[![example-mapping](docs/example-mapping.png)](docs/example-mapping.png)

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

Supported Relational Database Management Systems
------------------------------------------------

[](#supported-relational-database-management-systems)

- PostgreSQL

Table of compatibility
----------------------

[](#table-of-compatibility)

PHP 7.2PHP 7.3PHP 7.4Postgres 9✔️✔️✔️Postgres 10✔️✔️✔️Postgres 11✔️✔️✔️Postgres 12✔️✔️✔️MySQL 5.6.4+\*✔️✔️✔️MySQL 8✔️✔️✔️MariaDB 5.3+ \*\*✔️✔️✔️MariaDB 10✔️✔️✔️*\*Microseconds are supported since version 5.6.4 [\[source1\]](https://dev.mysql.com/doc/refman/5.6/en/fractional-seconds.html) [\[source2\]](https://stackoverflow.com/a/8790196)*

*\*\* Microseconds are supported since version 5.3 [\[source\]](https://mariadb.com/kb/en/microseconds-in-mariadb/#mysql-56-microseconds)*

Other Relational Database Management Systems
--------------------------------------------

[](#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

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance14

Infrequent updates — may be unmaintained

Popularity38

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 90.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~120 days

Recently: every ~240 days

Total

9

Last Release

1691d ago

Major Versions

0.0.5 → 1.0.02020-02-19

PHP version history (2 changes)0.0.5PHP ^7.2

1.0.2PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/d253b056a5d02ccd905173abe222bdcdea23a45e719f6ad7b54f1163eea41c66?d=identicon)[BartoszBartniczak](/maintainers/BartoszBartniczak)

---

Top Contributors

[![BartoszBartniczak](https://avatars.githubusercontent.com/u/6022713?v=4)](https://github.com/BartoszBartniczak "BartoszBartniczak (28 commits)")[![MekDrop](https://avatars.githubusercontent.com/u/342641?v=4)](https://github.com/MekDrop "MekDrop (3 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm

Code StyleECS

Type Coverage Yes

### Embed Badge

![Health badge](/badges/bartoszbartniczak-doctrine-datetime-with-microseconds/health.svg)

```
[![Health](https://phpackages.com/badges/bartoszbartniczak-doctrine-datetime-with-microseconds/health.svg)](https://phpackages.com/packages/bartoszbartniczak-doctrine-datetime-with-microseconds)
```

###  Alternatives

[codefog/contao-haste

haste extension for Contao Open Source CMS

42650.8k139](/packages/codefog-contao-haste)[eliashaeussler/typo3-form-consent

Extension for TYPO3 CMS that adds double opt-in functionality to EXT:form

1481.0k](/packages/eliashaeussler-typo3-form-consent)[ronasit/laravel-helpers

Provided helpers function and some helper class.

1475.7k13](/packages/ronasit-laravel-helpers)[inspiredminds/contao-fieldset-duplication

Contao extension to allow the duplication of form fieldsets in the front end by the user for additional input fields.

158.2k1](/packages/inspiredminds-contao-fieldset-duplication)[numero2/contao-storelocator

Contao Plugin for managing stores (or in common address data) and providing a frontend-search based on geo data

121.5k](/packages/numero2-contao-storelocator)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
