VulCode

Carbon: our changes to an open source project

A PHP DateTime extension for working with dates, standard in the Laravel ecosystem.

All contributions
Language
PHP
GitHub stars
16,591
Project site
carbon.nesbot.com
1merged change
Merged on 25 September 2026.
Number 11 of the 64 GitHub projects with our changes, by stars. First is Zed (91,587).

The change merged into Carbon

round(), floor() and ceil() with a precision of 60 seconds or more now carry into minutes, hours and days instead of only zeroing the seconds.

How we tested it

A new test compares numeric precisions with their string forms: round(3600) with round('hour'), round(120) with round('2 minutes'), round(86400) with round('day'), plus floor(3600) just before a full hour and ceil(3600) at half past.

PHP

Our projects in this technology, their screens and when we choose it.

The bug, the fix and the lesson

A summary of our Tech news write-up: what was broken, what we changed and what it means for our own work.

What was broken

round(3600) only cleared the seconds

For a numeric precision Carbon rounded only the seconds value, so from 60 upwards minutes and hours were never touched.

Carbon::parse('2026-01-01 14:21:37')->round(3600) -> 14:21:00 (instead of 14:00:00)
Carbon::parse('2026-01-01 14:30:00')->ceil(3600) -> 14:30:00 (instead of 15:00:00)
What we changed

Carried into larger units

A numeric precision that spans the whole next unit is carried upwards: 3600 seconds become 60 minutes, and 60 minutes an hour. Days are never carried into months.

What it taught us

Rounding time has to carry into larger units, just like addition.

An hour rounded to a full hour must not end at 60 minutes.

Other projects with our changes: PHP

20 projects in this technology have our merged changes. The bar is the repository's stars, next to it the number of our changes. Each row leads to the project's page.

Questions about our changes to Carbon

Where these changes come from, who merged them and whether we can fix something in your library.

Using Carbon in your project?

If something in it does not work, we fix it at the source and leave a workaround until the release. We reply within an hour.