briannesbitt/Carbon · error · Carbon\Exceptions\InvalidCastException
$className has not the instance() method needed to cast the
Error message
$className has not the instance() method needed to cast the date.
What it means
Error "$className has not the instance() method needed to cast the date." thrown in briannesbitt/Carbon.
Source
Thrown at src/Carbon/CarbonTimeZone.php:77
return $timezone;
}
/**
* Cast the current instance into the given class.
*
* @param class-string<DateTimeZone> $className The $className::instance() method will be called to cast the current object.
*
* @return DateTimeZone|mixed
*/
public function cast(string $className): mixed
{
if (!method_exists($className, 'instance')) {
if (is_a($className, DateTimeZone::class, true)) {
return new $className($this->getName());
}
throw new InvalidCastException("$className has not the instance() method needed to cast the date.");
}
return $className::instance($this);
}
/**
* Create a CarbonTimeZone from mixed input.
*
* @param DateTimeZone|string|int|false|null $object original value to get CarbonTimeZone from it.
* @param DateTimeZone|string|int|false|null $objectDump dump of the object for error messages.
*
* @throws InvalidTimeZoneException
*
* @return static|null
*/
public static function instance(
DateTimeZone|string|int|false|null $object,
DateTimeZone|string|int|false|null $objectDump = null,View on GitHub (pinned to b13f05955d)
When it happens
Trigger: Thrown at src/Carbon/CarbonTimeZone.php:77 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/ef7066a7d695b969.
Report an issue: GitHub.