Level 104
This will work... perhaps you were using the wrong format?
Carbon\Carbon::createFromFormat('d/m/Y H:i', '28/10/2022 16:08');
2 likes
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello,
I have a problem with parsing a string in data
ould not parse '28/10/2022 02:02': DateTime::__construct(): Failed to parse time string (28/10/2022 02:02) at position 0 (2): Unexpected character
My code
$cartProduct['gift_appointment'] = Carbon::parse($cartProduct['additional']['gift_appointment'])->format('Y-d-m H:i:s');
I also tried with createFromFormat but it doesn't work My string comes like "28/10/2022 16:08"
Please or to participate in this conversation.