PHP Memory Lane - Carbon NBD

Note: Opinions expressed on this site do not reflect the views of clients, employers, or any organizations affiliated with past or present.

A Trip Down Memory Lane with carbon-nbd

I spent a good chunk of my earlier career writing PHP. I do not write PHP much anymore, but some of that work has stuck around in a way that is still fun to see.

Carbon NBD came out of a business need: determining the next business day when weekends, holidays, special dates, and cutoff times all matter. It wraps the excellent Carbon DateTime library with a small, configurable calculator for those rules.

For example, add the built-in weekend rule and a Friday date becomes the following Monday:

use Carbon\Carbon;
use CarbonExt\NBD\Calculator;
use CarbonExt\NBD\CoreCallbacks as C;

$nbd = new Calculator();
$nbd->addCallback(C::noWeekends());

$nextBusinessDay = $nbd->nbd(new Carbon('2026-12-25')); // Friday: the next business day is Monday
// Carbon object for Monday, 2026-12-28

It is a modest library, but it is still published on Packagist and in use today by many. I have maintained it, modernized it, and kept it moving along over the years, even as PHP moved well outside my usual day-to-day work.

It recently celebrated a 3.0.0 release with PHP 8 support. It has also been a welcome reminder that carefully thought-out code makes maintenance a breeze, even when you only return to it now and then.

It is a nice reminder that a small piece of practical software can have a surprisingly long life. Find it on Packagist or GitHub.