Carbon::createFromFormat fails: separation symbol not found, trailing data or not enough data
Your error
Carbon\Exceptions\InvalidFormatException: The separation symbol could not be found3 more lines it can showFix it fast
Most common cause, 1 of 3The separators or the order in the format differ from the input
Write the format the way the input really arrives, and reject other shapes in validation before parsing.
$request->validate([
'starts_on' => ['required', 'date_format:d/m/Y'],
]);
$startsOn = Carbon::createFromFormat('!d/m/Y', $request->input('starts_on'));Short answer
"The separation symbol could not be found", "Trailing data" and "Not enough data available to satisfy format" come from PHP's date parser, rethrown by Carbon 3 as InvalidFormatException. The createFromFormat format does not match the string: other separators or order, extra text such as a time, or missing parts. Write the format for the exact input and validate with date_format.
Which cause do you have?
Run the same format and string through PHP's own parser and print its error list. Each entry is keyed by the character position where parsing stopped, which shows the exact spot the format and the input part ways.
php artisan tinker --execute="DateTimeImmutable::createFromFormat('Y-m-d', '21/11/2026'); dump(DateTimeImmutable::getLastErrors());"Then find the line you see in this list and open its fix:
- 1The separators or the order in the format differ from the input
The separation symbol could not be found, or A two digit month could not be found, at a low position in the string - 2The input carries more than the format describes
Trailing data, with the position pointing just after the part the format covers - 3The input is shorter than the format
Not enough data available to satisfy format (worded Data missing before PHP 8.1)
What does the error look like?
Carbon\Exceptions\InvalidFormatException: The separation symbol could not be foundCarbon\Exceptions\InvalidFormatException: Trailing dataNot enough data available to satisfy formatA two digit month could not be found
Cause 1 of 3
The separators or the order in the format differ from the input
You seeThe separation symbol could not be found, or A two digit month could not be found, at a low position in the string
Check
The separation symbol could not be found means the format expects one separator, such as the dash in Y-m-d, where the string has another, such as the slash in 21/11/2026. A day-first input read with a year-first format produces this and similar day, month or year errors. In Laravel 13, Eloquent date casts fall back to Carbon::parse when the format does not fit, so the failing call is almost always an explicit createFromFormat in your code.
grep -rn "createFromFormat(" app/Fix
Write the format the way the input really arrives, and reject other shapes in validation before parsing.
$request->validate([
'starts_on' => ['required', 'date_format:d/m/Y'],
]);
$startsOn = Carbon::createFromFormat('!d/m/Y', $request->input('starts_on'));Verify
With the corrected format the call returns a Carbon date for 21 November 2026 at midnight instead of throwing.
php artisan tinker --execute="dump(Carbon\Carbon::createFromFormat('!d/m/Y', '21/11/2026'))"Confirmed by github.com
Cause 2 of 3
The input carries more than the format describes
You seeTrailing data, with the position pointing just after the part the format covers
Check
Trailing data means the format matched the start of the string but text remained afterwards: a time after a date, fractional seconds, a T separator or a time zone suffix such as Z from a JavaScript ISO string.
php artisan tinker --execute="DateTimeImmutable::createFromFormat('Y-m-d', '2026-11-21 10:30:00'); dump(DateTimeImmutable::getLastErrors());"Fix
Add the remaining parts to the format. For a full ISO 8601 string, Carbon::parse reads it without a format. The + specifier turns trailing data into a warning, but only use it when the extra text really does not matter.
Carbon::createFromFormat('Y-m-d H:i:s', '2026-11-21 10:30:00');
// ISO 8601 from a browser, for example 2026-11-21T10:30:00.000Z
Carbon::parse($request->input('sent_at'));Verify
The value parses and the hours and minutes on the Carbon instance match the input.
php artisan tinker --execute="dump(Carbon\Carbon::createFromFormat('Y-m-d H:i:s', '2026-11-21 10:30:00')->format('H:i'))"Confirmed by php.net
Cause 3 of 3
The input is shorter than the format
You seeNot enough data available to satisfy format (worded Data missing before PHP 8.1)
Check
Not enough data available to satisfy format means the string ended while the format still had fields left, for example a date-only value read with Y-m-d H:i:s. PHP releases up to 8.0 reported the same case as Data missing.
php artisan tinker --execute="DateTimeImmutable::createFromFormat('Y-m-d H:i:s', '2026-11-21'); dump(DateTimeImmutable::getLastErrors());"Fix
Use a date-only format for date-only input. Prefix it with ! so the missing time fields become zero instead of the current time, which createFromFormat fills in otherwise.
$day = Carbon::createFromFormat('!Y-m-d', '2026-11-21'); // 2026-11-21 00:00:00Verify
The result shows midnight, not the time the code ran.
php artisan tinker --execute="dump(Carbon\Carbon::createFromFormat('!Y-m-d', '2026-11-21')->toDateTimeString())"Confirmed by php.net
How do I stop it coming back?
- Validate every user-supplied date with date_format using the same format string the parser uses, kept in one constant.
- Send dates from the front end as ISO 8601 and read them with Carbon::parse instead of hand-written formats.
- Start date-only formats with ! so stray current-time values never end up in stored dates.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine on the same stack: Spotless Laundry, EZ Estimater.