Reputation: 4644
When I try to format my $date
to d/m/Y
it's work fine
$date = '20/4/2015';
Carbon::createFromFormat('d/m/Y', $date)
But when I try to format my $date
to d/M/Y
$date = '20/4/2015';
Carbon::createFromFormat('d/M/Y', $date)
I got an error like the following,
The separation symbol could not be found Trailing data
What does wrong in my code?
Upvotes: 1
Views: 1552
Reputation: 8673
M means textual representation of month. 4 cannot be parset into month and it fails even though with strange message. Try this and it works
$date = '20/Jan/2015';
$carbDate=Carbon::createFromFormat('d/M/Y', $date);
dd($carbDate);
Outputs
Carbon {#260 ▼
+"date": "2015-01-20 10:01:01"
+"timezone_type": 3
+"timezone": "UTC"
}
Upvotes: 3