LLMpediaThe first transparent, open encyclopedia generated by LLMs

Carbon (date library)

Generated by GPT-5-mini
Note: This article was automatically generated by a large language model (LLM) from purely parametric knowledge (no retrieval). It may contain inaccuracies or hallucinations. This encyclopedia is part of a research project currently under review.
Article Genealogy
Expansion Funnel Raw 68 → Dedup 0 → NER 0 → Enqueued 0
1. Extracted68
2. After dedup0 (None)
3. After NER0 ()
4. Enqueued0 ()
Carbon (date library)
NameCarbon
TitleCarbon (date library)
DeveloperNuno Maduro
Released2011
Programming languagePHP
LicenseMIT License
Websitehttps://carbon.nesbot.com

Carbon (date library) is a widely used PHP library for date and time manipulation, offering an expressive API that extends DateTime capabilities. It aims to simplify parsing, formatting, arithmetic, and timezone handling for developers working with frameworks such as Laravel, Symfony, and Yii. Carbon integrates with popular PHP ecosystems including Composer packages, PHPUnit, and continuous integration systems like Travis CI and GitHub Actions.

Overview

Carbon was created to provide an intuitive API layered on top of PHP DateTime while adding convenience methods inspired by libraries in other languages, including Moment.js, Joda-Time, and date-fns. The project evolved alongside major PHP releases such as PHP 5.3, PHP 7, and PHP 8, and has been adopted in projects maintained by organizations like Automattic, Symfony, and Laravel LLC. Carbon's development and maintenance are influenced by community contributions on platforms like GitHub and discussions in ecosystems represented by Packagist, Stack Overflow, and various RFC threads.

Features

Carbon provides fluent methods for common operations including parsing ISO 8601, formatting for standards like RFC 3339 and ISO 8601, arithmetic (add/subtract days, months, years), and comparisons used in applications by companies such as Facebook and Google where reliable time handling is critical. It supports timezone conversions with integration to IANA Time Zone Database identifiers, locale-aware humanized strings similar to utilities used by Mozilla and Microsoft, and helper methods for start/end of period calculations employed in reporting systems at firms like Stripe and Shopify. Features extend to immutability modes akin to design choices in Clojure and Elm, and interval/range handling comparable to ICU libraries.

Installation and usage

Carbon is distributed through Packagist and installed with Composer in projects ranging from small plugins to enterprise platforms such as Drupal and Magento. Typical installation steps mirror patterns promoted in GitHub Guides and continuous delivery setups using Jenkins or CircleCI. Usage examples follow conventions familiar to developers who use PSR-4 autoloading, PHPUnit for testing, and frameworks like Laravel where Carbon often appears in documentation and middleware stacks. Community resources include tutorials on Stack Overflow, code samples in repositories by organizations like GitHub, and integrations highlighted at conferences such as PHP[tek] and SymfonyCon.

Internals and design

Internally, Carbon extends DateTimeImmutable or DateTime depending on configuration, employing object-oriented patterns inspired by libraries such as Doctrine and Monolog. The design emphasizes method chaining and readable intent, reflecting influences from Fluent interface styles used in Laravel Nova and Eloquent. Carbon relies on underlying PHP extensions and standards, including Intl for localization and the PCRE engine for parsing patterns, while following interoperability conventions from PSR-7 and PSR-17 where appropriate. Performance considerations reference benchmarking approaches used by projects like HHVM and Phalcon.

Compatibility and interoperability

Carbon maintains compatibility with multiple PHP versions as guided by policy discussions in PHP-FIG, and interoperates with libraries and platforms such as Guzzle, Symfony Console, and WordPress plugins. It integrates with serialization formats used by services like AWS and Google Cloud Platform, and supports date/time exchange with systems using ISO 8601 and RFC 3339 standards common in RESTful API ecosystems adopted by Twitter and GitHub. Interop extends to ORM layers including Eloquent and Doctrine ORM, as well as template engines like Twig and Blade.

Adoption and impact

Carbon's API has influenced time-handling practices across PHP projects from startups to enterprises including Netflix, Spotify, and e‑commerce platforms such as WooCommerce and Magento. Educational materials and books on PHP development reference Carbon alongside tooling from Composer and testing frameworks like PHPUnit. The library's presence in open-source ecosystems on GitHub and package registries like Packagist has shaped developer expectations for convenience and expressiveness in date/time libraries, paralleling the influence of Moment.js in the JavaScript world and Joda-Time in the Java ecosystem.

Category:PHP libraries