briannesbitt/Carbon · error · Carbon\Exceptions\InvalidIntervalException
Rounding is only possible with single unit intervals.
Error message
Rounding is only possible with single unit intervals.
What it means
Error "Rounding is only possible with single unit intervals." thrown in briannesbitt/Carbon.
Source
Thrown at src/Carbon/Traits/IntervalRounding.php:50
if (\in_array($action, ['round', 'floor', 'ceil'])) {
return $this->{$action.'Unit'}(substr($method, \strlen($action)), ...$parameters);
}
return null;
}
protected function roundWith(DateInterval|string|float|int $precision, callable|string $function): ?static
{
$unit = 'second';
if ($precision instanceof DateInterval) {
$precision = CarbonInterval::instance($precision)->forHumans(['locale' => 'en']);
}
if (\is_string($precision) && preg_match('/^\s*(?<precision>\d+)?\s*(?<unit>\w+)(?<other>\W.*)?$/', $precision, $match)) {
if (trim($match['other'] ?? '') !== '') {
throw new InvalidIntervalException('Rounding is only possible with single unit intervals.');
}
$precision = (int) ($match['precision'] ?: 1);
$unit = $match['unit'];
}
return $this->roundUnit($unit, $precision, $function);
}
}
View on GitHub (pinned to b13f05955d)
When it happens
Trigger: Thrown at src/Carbon/Traits/IntervalRounding.php:50 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of briannesbitt/Carbon@b13f05955d (2026-08-17).
Data as JSON: /api/errors/722b1ac1ef438e9b.
Report an issue: GitHub.