PHPackages                             damejidlo/datetime-factory - 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. damejidlo/datetime-factory

AbandonedArchivedLibrary

damejidlo/datetime-factory
==========================

2.0.0(8y ago)7107.0k1MITPHPPHP &gt;=7.1

Since Apr 1Pushed 8y ago13 watchersCompare

[ Source](https://github.com/damejidlo/datetime-factory)[ Packagist](https://packagist.org/packages/damejidlo/datetime-factory)[ RSS](/packages/damejidlo-datetime-factory/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (5)Versions (5)Used By (0)

[![Downloads this Month](https://camo.githubusercontent.com/d6dadcc6f6c3f12b27604c86666a3d7a26cbbf754f9d6ea5f92b18f7caf54d8a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f64616d656a69646c6f2f6461746574696d652d666163746f72792e737667)](https://packagist.org/packages/damejidlo/datetime-factory)[![Latest Stable Version](https://camo.githubusercontent.com/7d24dd6a164af010783c0010e8242c699b58f2b38041dc59b26f3f6b5dd6e130/68747470733a2f2f706f7365722e707567782e6f72672f64616d656a69646c6f2f6461746574696d652d666163746f72792f762f737461626c65)](https://github.com/damejidlo/datetime-factory/releases)[![](https://camo.githubusercontent.com/8ef4da16080e2f9f8d50669a3f5fd82e54db2206c4e77f8e4cea4f20596612c8/68747470733a2f2f7472617669732d63692e6f72672f64616d656a69646c6f2f6461746574696d652d666163746f72792e7376673f6272616e63683d6d6173746572)](https://camo.githubusercontent.com/8ef4da16080e2f9f8d50669a3f5fd82e54db2206c4e77f8e4cea4f20596612c8/68747470733a2f2f7472617669732d63692e6f72672f64616d656a69646c6f2f6461746574696d652d666163746f72792e7376673f6272616e63683d6d6173746572)[![](https://camo.githubusercontent.com/2ff5e45497f62774389ea8af272aef2a8eac2bfe5eb6aaf72c1564725885e431/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f64616d656a69646c6f2f6461746574696d652d666163746f72792f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://camo.githubusercontent.com/2ff5e45497f62774389ea8af272aef2a8eac2bfe5eb6aaf72c1564725885e431/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f64616d656a69646c6f2f6461746574696d652d666163746f72792f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)[![](https://camo.githubusercontent.com/f7672a9d55987571488702d2dc20d091b74af27ac5de2a4dd18e36431cca788c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f64616d656a69646c6f2f6461746574696d652d666163746f72792f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://camo.githubusercontent.com/f7672a9d55987571488702d2dc20d091b74af27ac5de2a4dd18e36431cca788c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f64616d656a69646c6f2f6461746574696d652d666163746f72792f6261646765732f636f7665726167652e706e673f623d6d6173746572)

Motivation
==========

[](#motivation)

In our application you should never obtain NOW via `new DateTime()` or from SQL `NOW()`. Because it's unmockable and therefore untestable.

This ultra-simple library provides service you can easily use and mock.

Install
=======

[](#install)

```
composer require damejidlo/datetime-factory

```

And then just register it in your `config.neon` as a service.

Example (of mocking in tests)
=============================

[](#example-of-mocking-in-tests)

```
public function testXyz(\DateTimeImmutable $subjectTime)
{
    $container = $this->createContainer();
    $dateTimeFactory = Mockery::mock(DateTimeFactoryImmutable::class);
    $dateTimeFactory->shouldReceive('getNow')->andReturn($subjectTime);
    $container->removeService('dateTimeFactory');
    $container->addService('dateTimeFactory', $dateTimeFactory);
}
```

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~225 days

Total

4

Last Release

3012d ago

Major Versions

1.1 → 2.0.02018-02-08

PHP version history (2 changes)1.0.0PHP &gt;= 5.6.0

2.0.0PHP &gt;=7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/5b4780fe328102c4572737db639653c29d3081d1d3e051467f00d7f09a776399?d=identicon)[xificurk](/maintainers/xificurk)

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

![](https://www.gravatar.com/avatar/295525512eb83035f5ec07a5a94e0c4be2a2ac3ac2d06e3774a24e1bac2e118b?d=identicon)[legendik](/maintainers/legendik)

---

Top Contributors

[![xificurk](https://avatars.githubusercontent.com/u/117465?v=4)](https://github.com/xificurk "xificurk (7 commits)")[![legendik](https://avatars.githubusercontent.com/u/2327491?v=4)](https://github.com/legendik "legendik (4 commits)")[![RadekDvorak](https://avatars.githubusercontent.com/u/672781?v=4)](https://github.com/RadekDvorak "RadekDvorak (2 commits)")[![honzalilak](https://avatars.githubusercontent.com/u/1928926?v=4)](https://github.com/honzalilak "honzalilak (1 commits)")[![VaclavSir](https://avatars.githubusercontent.com/u/1473642?v=4)](https://github.com/VaclavSir "VaclavSir (1 commits)")

### Embed Badge

![Health badge](/badges/damejidlo-datetime-factory/health.svg)

```
[![Health](https://phpackages.com/badges/damejidlo-datetime-factory/health.svg)](https://phpackages.com/packages/damejidlo-datetime-factory)
```

###  Alternatives

[nette/php-generator

🐘 Nette PHP Generator: generates neat PHP code for you. Supports new PHP 8.5 features.

2.2k64.2M575](/packages/nette-php-generator)[nette/caching

⏱ Nette Caching: library with easy-to-use API and many cache backends.

43518.6M367](/packages/nette-caching)[nette/mail

📧 Nette Mail: A handy library for creating and sending emails in PHP.

5389.8M244](/packages/nette-mail)[symplify/monorepo-builder

Not only Composer tools to build a Monorepo.

5205.3M82](/packages/symplify-monorepo-builder)[ssch/typo3-rector

Instant fixes for your TYPO3 PHP code by using Rector.

2592.8M262](/packages/ssch-typo3-rector)[rector/rector-src

Instant Upgrade and Automated Refactoring of any PHP code

134391.5k12](/packages/rector-rector-src)

PHPackages © 2026

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