I have an array that returns the following date time:
$item['created_at'] => "2015-10-28 19:18:44"
How do I change the date to M d Y
format in Laravel using Carbon?
Currently it returns with an error
$suborder['payment_date'] = $item['created_at']->format('M d Y');
First parse the created_at field as Carbon object.
$createdAt = Carbon::parse($item['created_at']);
Then you can use
$suborder['payment_date'] = $createdAt->format('M d Y');