A standalone immutable DateTime library for PHP with date, time, and calendar date objects.
Chronos is a standalone PHP library for handling dates and times, focusing on immutable objects to prevent accidental modifications. It provides datetime, date-only, and time-only objects with a clean API, originally based on Carbon but now independent. It solves the problem of unpredictable datetime mutations in applications by enforcing immutability.
PHP developers building applications that require reliable and predictable datetime handling, such as scheduling systems, calendar features, or financial applications. It's also suitable for developers who need PSR-20 compliance or enhanced testing capabilities.
Developers choose Chronos for its strict immutability, which eliminates side-effects and accidental datetime changes, ensuring data integrity. It offers additional utilities like calendar dates and time-only objects, along with testing support, making it more comprehensive than basic PHP datetime functions.
A standalone DateTime library originally based off of Carbon
Enforces immutability to prevent accidental datetime changes, ensuring predictable and side-effect-free code as emphasized in the README's philosophy.
Provides ChronosDate for date-only operations with time frozen at 00:00:00, ideal for handling calendar features without time interference.
Includes ChronosTime for scenarios like schedules or business hours, with dedicated methods such as addHours() for arithmetic on time-only values.
Offers setTestNow() to freeze time during unit tests, making results predictable and reliable, as demonstrated in the README examples.
Implements ClockFactory for the PSR-20 interface, facilitating dependency injection and modern PHP application standards.
Requires developers to always reassign modified objects, as shown in the README where failing to do so loses changes, which can be error-prone and less intuitive than mutable alternatives.
Diverges from Carbon and no longer extends PHP's DateTime classes, breaking compatibility and making migration from Carbon non-trivial without API adjustments.
Has a smaller community and fewer third-party extensions compared to Carbon, which may limit support, integrations, and available learning resources.
A simple PHP API extension for DateTime.
Send your projects up in the clouds
A Multi-Framework Composer Library Installer
The easy PHP Library for calculating holidays
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.