0
votes

I'm facing an odd issue, Carbon::parse("25/10/1980") throws the following error:

Exception with message 'DateTime::__construct(): Failed to parse time string (25/12/1980) at position 0 (2): Unexpected character'

While having no problems whatsoever, if month (10) is swapped places with day (25) like this:

Carbon::parse("10/25/1980")

How should I parse the "d/m/Y" string?

2

2 Answers

7
votes

Try this:

Carbon::createFromFormat('d/m/Y', '25/10/1980');
2
votes

This also works (dashes, not slashes)

Carbon::parse ('25-10-1980');