PHPackages                             phpnomad/chronos-integration - 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. phpnomad/chronos-integration

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

phpnomad/chronos-integration
============================

Chronos-backed implementation of the phpnomad/chrono catalog. One concrete class fulfilling every non-platform chrono interface against cakephp/chronos.

1.0.0(1mo ago)00MITPHPPHP &gt;=8.2

Since May 27Pushed 1mo agoCompare

[ Source](https://github.com/phpnomad/chronos-integration)[ Packagist](https://packagist.org/packages/phpnomad/chronos-integration)[ Docs](https://github.com/phpnomad/chronos-integration)[ RSS](/packages/phpnomad-chronos-integration/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

PHPNomad Chronos Integration
============================

[](#phpnomad-chronos-integration)

Chronos-backed implementation of the [`phpnomad/chrono`](https://github.com/phpnomad/chrono) catalog. Ships one concrete class, `ChronosChronoStrategy`, that fulfills every non-platform chrono interface against [`cakephp/chronos`](https://github.com/cakephp/chronos) — with `IntlDateFormatter` providing the locale-aware formatting that Chronos 3.x dropped.

The default comprehensive integration for chrono. About a fifth the install footprint of `nesbot/carbon` with effectively the same surface, plus locale support through `ext-intl` instead of bundled translation files.

Requirements
------------

[](#requirements)

PHP 8.2 or newer, `ext-intl`, `phpnomad/chrono ^1.0`, `cakephp/chronos ^2.4 || ^3.0`.

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

[](#installation)

```
composer require phpnomad/chronos-integration
```

The package's `Initializer` registers `ChronosChronoStrategy` against the chrono catalog. Apps using PHPNomad's loader pick this up automatically.

What gets bound
---------------

[](#what-gets-bound)

A single `ChronosChronoStrategy` instance fulfills these 28 chrono interfaces:

- `ClockStrategy`
- `CanCheckIfPast`, `CanCheckIfFuture`, `CanCheckIfWeekend`, `CanCheckIfWeekday`
- `CanCheckSameDay`, `CanCheckSameMonth`, `CanCheckSameYear`, `CanCheckBetween`
- `CanApplyModifier`, `CanAddInterval`, `CanSubtractInterval`
- `CanGetStartOfDay`, `CanGetEndOfDay`, `CanGetStartOfMonth`, `CanGetEndOfMonth`, `CanGetStartOfYear`, `CanGetEndOfYear`
- `CanGetDifference`, `CanGetDifferenceInDays`, `CanGetDifferenceInHours`, `CanGetDifferenceInMinutes`, `CanGetDifferenceInSeconds`
- `CanParseDate`, `CanParseDateWithFormat`
- `CanFormatDate`, `CanFormatLocalizedDate`, `CanFormatRelativeTime`

What does NOT get bound here
----------------------------

[](#what-does-not-get-bound-here)

`HasTimezone` and `HasLocale` are intentionally not implemented by this integration. Chronos does not own the platform's timezone or locale; those come from the host environment.

The `ChronosChronoStrategy` constructor declares both as dependencies:

```
public function __construct(
    HasTimezone $timezone,
    HasLocale   $locale,
)
```

Pair with [`phpnomad/wordpress-integration`](https://github.com/phpnomad/wordpress-integration) (which resolves both from WordPress site settings) or supply your own concretes. Without a `HasTimezone` and `HasLocale` binding in the container, the strategy cannot be instantiated.

Model-side chrono interfaces (`HasCreatedDate`, `HasModifiedDate`) are likewise not implemented here — they are contracts for domain models, not platform capabilities.

Behavior notes
--------------

[](#behavior-notes)

- **Format string syntax differs across methods.** `format()` takes PHP's native `date()` syntax. `formatLocalized()` takes ICU pattern syntax via `IntlDateFormatter` — see [the ICU patterns reference](https://unicode-org.github.io/icu/userguide/format_parse/datetime/) for the grammar.
- **`relative()` is English-only.** Chronos 3.x ships a deliberately English-only `diffForHumans` translator, so the injected locale is ignored by this method. Apps needing locale-aware relative-time strings should pair with `phpnomad/wordpress-integration` (which uses WordPress's translation pipeline against `human_time_diff()`) or `phpnomad/carbon-integration` (Carbon ships 281 locales).
- **`isBetween` is inclusive on both bounds**, matching Chronos's `between(true)` default.
- **`apply()` uses native `DateTimeImmutable::modify()`**, so PHP's default month-overflow behavior applies. Prefer `CanAddInterval` with explicit intervals for safer math.
- **`parseFormat()` throws `InvalidArgumentException`** when the input cannot be parsed against the supplied format.
- **`diffIn*` methods are signed.** `diffInDays($a, $b)` returns positive when `$b` is after `$a` and negative otherwise.
- **Chronos's `setTestNow()` is honored** by `now()` and therefore by every predicate that consults it, which makes the whole strategy deterministic in tests.

Testing in your own app
-----------------------

[](#testing-in-your-own-app)

Because `now()` delegates to `Chronos::now()`, Chronos's built-in test helper works without any chrono-specific machinery:

```
use Cake\Chronos\Chronos;

Chronos::setTestNow('2026-05-27 12:00:00');
// ... exercise code that uses ChronosChronoStrategy
Chronos::setTestNow(); // clear
```

For PSR-20-style fixed clocks, bind any PSR-20 implementation directly to `ClockStrategy` in your DI container — it will replace just the clock binding while leaving the rest of the Chronos-backed cluster intact.

Why Chronos and not Carbon
--------------------------

[](#why-chronos-and-not-carbon)

Chronos is a CakePHP-maintained immutable datetime library that started as a fork of early Carbon and has stayed disciplined about scope. The trade-offs:

- **Roughly five times lighter than Carbon** by file count and dependency footprint
- **No bundled translation files** — uses `ext-intl` (bundled with most PHP distributions) for locale-aware formatting
- **Same API shape as Carbon for the methods chrono uses** — drop-in equivalent
- **English-only `diffForHumans`** is the one real concession; pair with a locale-aware integration if needed

If you already have Carbon in your stack (Laravel apps especially), use [`phpnomad/carbon-integration`](https://github.com/phpnomad/carbon-integration) — there's no marginal cost since Carbon is already loaded.

License
-------

[](#license)

[MIT](LICENSE.txt)

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance88

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

58d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9e6206223bd6f2a57b8ac80605b1b5c3521faaec18ad3f20f25fb728a9a13784?d=identicon)[tstandiford](/maintainers/tstandiford)

---

Top Contributors

[![alexstandiford](https://avatars.githubusercontent.com/u/8210827?v=4)](https://github.com/alexstandiford "alexstandiford (1 commits)")

---

Tags

cakephpchronochronosclockintegrationphpnomadtimeclockcakephptimeintegrationchronochronosphpnomad

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/phpnomad-chronos-integration/health.svg)

```
[![Health](https://phpackages.com/badges/phpnomad-chronos-integration/health.svg)](https://phpackages.com/packages/phpnomad-chronos-integration)
```

###  Alternatives

[symfony/clock

Decouples applications from the system clock

433205.7M428](/packages/symfony-clock)[icecave/chrono

A date &amp; time library that is decoupled from the system clock.

53195.7k7](/packages/icecave-chrono)[kdyby/datetime-provider

Time provider, providing consistent current date, time, datetime and timezone across the request.

1146.8k2](/packages/kdyby-datetime-provider)

PHPackages © 2026

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