You dumping $dateWanted
Post the result here
dd($dateWanted);
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am sending data through Soap. The XML format accepts date("Y-m-d). My request format is date("m-d-Y). I like the format in my app, so I don't want to change it, I only wanna change it for the API. I tried to use CarbonFromdate to format it but I am getting errors
Unexpected data found. Unexpected data found.
tried this 1st
$dateWanted = $request->date_wanted;
$timeZone = \date_default_timezone_get();
$dateObject = Carbon::createFromFormat("m-d-Y", $dateWanted, $timeZone);
2nd Try
$dateWanted = $request->date_wanted;
$dateObject = Carbon::createFromFormat("m-d-Y", $dateWanted)->format('Y-m-d')
There you go. It is / not -
$dateWanted = $request->date_wanted;
$dateObject = Carbon::createFromFormat("m/d/Y", $dateWanted)->format('Y-m-d')
Please or to participate in this conversation.