Level 16
i is minutes, not m. You are adding the month at the end of the time.
Change it:
\Carbon\Carbon::parse($datetimes[0])->format('d M, H:iA')
=> "13 Jul, 08:00AM"
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
My request returns
"07/13/2020 8:00 AM - 07/17/2020 5:00 PM"
Then explode
$datetimes = explode(' - ', $request->datetimes);
dd($datetimes[0])
"07/13/2020 8:00 AM"
Format string with carbon
\Carbon\Carbon::parse($datetimes[0])->format('d M, H:mA')
Returns
"13 Jul, 08:07AM"
i is minutes, not m. You are adding the month at the end of the time.
Change it:
\Carbon\Carbon::parse($datetimes[0])->format('d M, H:iA')
=> "13 Jul, 08:00AM"
Please or to participate in this conversation.