Generated by GPT-5-mini| Carbon (date library) | |
|---|---|
| Name | Carbon |
| Title | Carbon (date library) |
| Developer | Nuno Maduro |
| Released | 2011 |
| Programming language | PHP |
| License | MIT License |
| Website | https://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.
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.
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.
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.
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.
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.
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