A simple API extension for DateTime.

Installs: 66 295 039

Dependents: 2 036

Suggesters: 35

Stars: 11 318

Watchers: 259

Forks: 1 042

Open Issues: 1


Latest Stable Version Total Downloads Build Status StyleCI PHPStan Tidelift

A simple PHP API extension for DateTime.

use Carbon\Carbon;

printf("Right now is %s", Carbon::now()->toDateTimeString());
printf("Right now in Vancouver is %s", Carbon::now('America/Vancouver'));  //implicit __toString()
$tomorrow = Carbon::now()->addDay();
$lastWeek = Carbon::now()->subWeek();
$nextSummerOlympics = Carbon::createFromDate(2016)->addYears(4);

$officialDate = Carbon::now()->toRfc2822String();

$howOldAmI = Carbon::createFromDate(1975, 5, 21)->age;

$noonTodayLondonTime = Carbon::createFromTime(12, 0, 0, 'Europe/London');

$internetWillBlowUpOn = Carbon::create(2038, 01, 19, 3, 14, 7, 'GMT');

// Don't really want this to happen so mock now
Carbon::setTestNow(Carbon::createFromDate(2000, 1, 1));

// comparisons are always done in UTC
if (Carbon::now()->gte($internetWillBlowUpOn)) {

// Phew! Return to normal behaviour

if (Carbon::now()->isWeekend()) {
    echo 'Party!';
echo Carbon::now()->subMinutes(2)->diffForHumans(); // '2 minutes ago'

// ... but also does 'from now', 'after' and 'before'
// rolling up to seconds, minutes, hours, days, months, years

$daysSinceEpoch = Carbon::createFromTimestamp(0)->diffInDays();

Get supported nesbot/carbon with the Tidelift Subscription


With Composer

$ composer require nesbot/carbon
    "require": {
        "nesbot/carbon": "^1.33"
require 'vendor/autoload.php';

use Carbon\Carbon;

printf("Now: %s", Carbon::now());

Without Composer

Why are you not using composer? Download the Carbon latest release and put the contents of the ZIP archive into a directory in your project. Then require the file autoload.php to get all classes and dependencies loaded on need.

require 'path-to-Carbon-directory/autoload.php';

use Carbon\Carbon;

printf("Now: %s", Carbon::now());


Security contact information

To report a security vulnerability, please use the Tidelift security contact. Tidelift will coordinate the fix and disclosure.