3 [![Latest Stable Version](https://poser.pugx.org/nesbot/carbon/v/stable.png)](https://packagist.org/packages/nesbot/carbon)
4 [![Total Downloads](https://poser.pugx.org/nesbot/carbon/downloads.png)](https://packagist.org/packages/nesbot/carbon)
5 [![Build Status](https://travis-ci.org/briannesbitt/Carbon.svg?branch=master)](https://travis-ci.org/briannesbitt/Carbon)
6 [![StyleCI](https://styleci.io/repos/5724990/shield?style=flat)](https://styleci.io/repos/5724990)
7 [![codecov.io](https://codecov.io/github/briannesbitt/Carbon/coverage.svg?branch=master)](https://codecov.io/github/briannesbitt/Carbon?branch=master)
8 [![PHP-Eye](https://php-eye.com/badge/nesbot/carbon/tested.svg?style=flat)](https://php-eye.com/package/nesbot/carbon)
9 [![PHPStan](https://img.shields.io/badge/PHPStan-enabled-brightgreen.svg?style=flat)](https://github.com/phpstan/phpstan)
11 A simple PHP API extension for DateTime. [http://carbon.nesbot.com](http://carbon.nesbot.com)
16 printf("Right now is %s", Carbon::now()->toDateTimeString());
17 printf("Right now in Vancouver is %s", Carbon::now('America/Vancouver')); //implicit __toString()
18 $tomorrow = Carbon::now()->addDay();
19 $lastWeek = Carbon::now()->subWeek();
20 $nextSummerOlympics = Carbon::createFromDate(2016)->addYears(4);
22 $officialDate = Carbon::now()->toRfc2822String();
24 $howOldAmI = Carbon::createFromDate(1975, 5, 21)->age;
26 $noonTodayLondonTime = Carbon::createFromTime(12, 0, 0, 'Europe/London');
28 $internetWillBlowUpOn = Carbon::create(2038, 01, 19, 3, 14, 7, 'GMT');
30 // Don't really want this to happen so mock now
31 Carbon::setTestNow(Carbon::createFromDate(2000, 1, 1));
33 // comparisons are always done in UTC
34 if (Carbon::now()->gte($internetWillBlowUpOn)) {
38 // Phew! Return to normal behaviour
41 if (Carbon::now()->isWeekend()) {
44 echo Carbon::now()->subMinutes(2)->diffForHumans(); // '2 minutes ago'
46 // ... but also does 'from now', 'after' and 'before'
47 // rolling up to seconds, minutes, hours, days, months, years
49 $daysSinceEpoch = Carbon::createFromTimestamp(0)->diffInDays();
57 $ composer require nesbot/carbon
63 "nesbot/carbon": "~1.21"
70 require 'vendor/autoload.php';
74 printf("Now: %s", Carbon::now());
77 <a name="install-nocomposer"/>
81 Why are you not using [composer](http://getcomposer.org/)? Download [Carbon.php](https://github.com/briannesbitt/Carbon/blob/master/src/Carbon/Carbon.php) from the repo and save the file into your project path somewhere.
85 require 'path/to/Carbon.php';
89 printf("Now: %s", Carbon::now());
94 [http://carbon.nesbot.com/docs](http://carbon.nesbot.com/docs)