Search code examples
sql-serverlaraveldatetime2

Issue with converting a date using Carbon


$value="Mar 10 2016 09:12:03:000AM";
return Carbon::createFromFormat('Y-m-d H:i:s.u0', $value);

Please will someone please tell me how to use Carbon to convert this date to that format.

I'm getting: InvalidArgumentException in Carbon.php line 425: Unexpected data found. Unexpected data found. The separation symbol could not be found Unexpected data found. The format separator does not match Trailing data


Solution

  • use carbon like

    $value="Mar 10 2016 09:12:03:000AM";
    return \Carbon\Carbon::parse($value)->format('Y-m-d H:i:s.u0');