Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. CakePHP
  3. Chronos

Chronos

MITPHP3.5.0

A standalone immutable DateTime library for PHP with date, time, and calendar date objects.

Visit WebsiteGitHubGitHub
1.4k stars71 forks0 contributors

What is Chronos?

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.

Target Audience

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.

Value Proposition

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.

Overview

A standalone DateTime library originally based off of Carbon

Use Cases

Best For

  • Building applications where datetime consistency is critical, like financial or scheduling systems
  • Implementing calendar features that require date-only operations without time components
  • Handling time-only data such as business hours or recurring schedules
  • Writing predictable and reliable unit tests by freezing time with `setTestNow()`
  • Adopting PSR-20 standards for dependency injection in modern PHP applications
  • Replacing Carbon with a more focused and immutable datetime library

Not Ideal For

  • Projects requiring mutable datetime objects for in-place modifications and performance optimizations
  • Teams with extensive Carbon-based codebases seeking a drop-in replacement without refactoring
  • Simple, one-off scripts where the overhead of immutability and reassignment adds unnecessary complexity

Pros & Cons

Pros

Strict Immutability

Enforces immutability to prevent accidental datetime changes, ensuring predictable and side-effect-free code as emphasized in the README's philosophy.

Calendar Date Support

Provides ChronosDate for date-only operations with time frozen at 00:00:00, ideal for handling calendar features without time interference.

Time-Only Handling

Includes ChronosTime for scenarios like schedules or business hours, with dedicated methods such as addHours() for arithmetic on time-only values.

Testing Utilities

Offers setTestNow() to freeze time during unit tests, making results predictable and reliable, as demonstrated in the README examples.

PSR-20 Compliance

Implements ClockFactory for the PSR-20 interface, facilitating dependency injection and modern PHP application standards.

Cons

Mandatory Reassignment Overhead

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.

Carbon Incompatibility

Diverges from Carbon and no longer extends PHP's DateTime classes, breaking compatibility and making migration from Carbon non-trivial without API adjustments.

Smaller Ecosystem

Has a smaller community and fewer third-party extensions compared to Carbon, which may limit support, integrations, and available learning resources.

Frequently Asked Questions

Quick Stats

Stars1,361
Forks71
Contributors0
Open Issues2
Last commit7 days ago
CreatedSince 2015

Tags

#date-manipulation#library#datetime#time#testing#immutable-objects#immutable#php

Built With

P
PHP

Links & Resources

Website

Included in

PHP32.5kCakePHP932
Auto-fetched 55 minutes ago

Related Projects

CarbonCarbon

A simple PHP API extension for DateTime.

Stars16,620
Forks1,294
Last commit22 hours ago
RocketeerRocketeer

Send your projects up in the clouds

Stars2,638
Forks217
Last commit5 years ago
Composer InstallersComposer Installers

A Multi-Framework Composer Library Installer

Stars1,439
Forks404
Last commit24 days ago
YasumiYasumi

The easy PHP Library for calculating holidays

Stars1,087
Forks167
Last commit1 day ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub