Answers for "carbon "could not parse '2': datetime::__construct(): failed to parse time string (2) at position 0 (2): unexpected character"\"

PHP
0

laravel carbon Could not parse '28/09/2021, 12:00:00 pm': DateTime::__construct(): Failed to parse time string (28/09/2021, 12:00:00 pm) at position 0 (2): Unexpected character

Because Carbon does not understand d/m/Y format out of the box. If you use 
slashes it should be mm/dd/yyyy in that case. d/m/Y is not an official date 
format.

You can use :
{{ CarbonCarbon::createFromFormat('d/m/Y', $holiday->holiday_date)->format('d-m-Y') }}
Posted by: Guest on September-28-2021

Code answers related to "carbon "could not parse '2': datetime::__construct(): failed to parse time string (2) at position 0 (2): unexpected character"\"

Browse Popular Code Answers by Language