Home > Net >  DateTime::__construct(): Failed to parse time string (May 5 2022 12:00:00:AM) at position 20 (:): Un
DateTime::__construct(): Failed to parse time string (May 5 2022 12:00:00:AM) at position 20 (:): Un

Time:06-01

I'm having the following error

"

ErrorException in /*/web/vendor/nesbot/carbon/src/Carbon/Carbon.php line 555:
DateTime::__construct(): Failed to parse time string (May 5 2022 12:00:00:AM) at position 20 (:): Unexpected character

In my list file,

{{ Carbon\Carbon::parse($r->AttendanceDate)->format('d/m/Y') }}         

    

The date in sql is a date time "2020-05-20 08:13:00.000"

I've tried some changes like format from DateTime to format to day, I've tried also to parse string and nothing worked.. I've seen some post with the same error but nothing result. Please help me

CodePudding user response:

"Failed to parse time string (May 5 2022 12:00:00:AM)" is very clear. It can't parse that format. You can tell Carbon what format to expect using the Carbon::createFromFormat method.

Carbon::createFromFormat('M j Y h:i:s:A', 'May 5 2022 12:00:00:AM');

Format definitions are from PHP's DateTime::createFromFormat() method.

  • Related