2
$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

JoeAny
  • 23
  • 1
  • 4

3 Answers3

2

use carbon like

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

For detail about how to carbon module used please visit on link Carbon Docs

In controller declare use Carbon\Carbon;

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

Use parse method to instantiate the $value string as carbon object and then you can use any of the helper functions available in Carbon Library. Refer to the given link :: http://carbon.nesbot.com/docs/#api-formatting.

dpak005
  • 241
  • 4
  • 10