PHPackages                             vasek-purchart/doctrine-date-time-immutable-types - 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. vasek-purchart/doctrine-date-time-immutable-types

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

vasek-purchart/doctrine-date-time-immutable-types
=================================================

Doctrine DateTimeImmutable types

1.0.1(8y ago)42228.3k↓35.5%7MITPHPPHP ~7.0

Since Jun 2Pushed 7y ago3 watchersCompare

[ Source](https://github.com/VasekPurchart/Doctrine-Date-Time-Immutable-Types)[ Packagist](https://packagist.org/packages/vasek-purchart/doctrine-date-time-immutable-types)[ RSS](/packages/vasek-purchart-doctrine-date-time-immutable-types/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (6)Versions (8)Used By (0)

Doctrine DBAL DateTimeImmutable Types
=====================================

[](#doctrine-dbal-datetimeimmutable-types)

> In [Doctrine DBAL 2.6](https://github.com/doctrine/dbal/releases/tag/v2.6.0) immutable DateTime types were added, so if you are using that version or newer, you no longer need this package. If you cannot use that version (it requires PHP 7.1), keep using this package (you can find even PHP 5.6 version in the older versions).

### Why would I want to use immutable types?

[](#why-would-i-want-to-use-immutable-types)

All Doctrine date/time based types are using `DateTime` instances, which are mutable. This can lead to breaking encapsulation and therefore bugs. For two reasons:

1. You accidentally modify a date when you are doing some computation on it:

```
