cakephp/chronos
Chronos provides immutable date/time objects for PHP, helping prevent accidental mutations and side effects. Includes ChronosDate for calendar dates fixed at 00:00:00, plus convenient APIs inspired by Carbon but no longer extending DateTime.
setTestNow()) or scoped (withTestNow()), reducing flakiness in CI/CD pipelines and unit tests.ChronosDate: Optimized for calendar operations (e.g., event scheduling, date ranges) where time components are irrelevant.ChronosTime: Useful for business hours, recurring tasks, or time-only comparisons (e.g., "Is this order within support hours?").addElapsedHours(), diffInSeconds()), critical for global applications or time-sensitive workflows.DateTime logic with modern, immutable alternatives, reducing technical debt during migrations (e.g., PHP 8.4+ compatibility).ChronosPeriod.toRfc7231String() for HTTP headers).DateTime (though Chronos adds minimal overhead).DateTime).v7 timestamps) without datetime manipulation."Chronos is a lightweight, MIT-licensed PHP library that eliminates bugs caused by accidental datetime modifications—think of it as ‘immutable timestamps on autopilot.’
DateTime with backward-compatible APIs. Used by CakePHP (enterprise-grade).*"Chronos replaces mutable DateTime with immutable objects, solving:
->modify() silently altering shared timestamps.Chronos::setTestNow()) or per-test (withTestNow()).ClockInterface for DI, DST-safe arithmetic, and time/date specialization (ChronosTime, ChronosDate).Chronos::now() in new features.toNative() to convert legacy DateTime objects.Carbon where immutability is critical (e.g., financial transactions).// Before (bug-prone)
$order->created_at->modify('+1 hour'); // Affects other code!
// After (safe)
$order->created_at = $order->created_at->addHours(1); // Immutable
```"*
How can I help you explore Laravel packages today?