Carbon: our changes to an open source project
A PHP DateTime extension for working with dates, standard in the Laravel ecosystem.
- Language
- PHP
- GitHub stars
- 16,591
- Project site
- carbon.nesbot.com
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.
- Pull request #3359merged on 25 September 2026
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.
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.
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.
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.
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.
Read next
More about this work and the other projects with our changes.
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.