aradhya
aradhya

Reputation: 355

Laravel 4 Carbon trailing data error

I am getting the following error when retrieving a timestamp field from my database and converting it to json for response.

InvalidArgumentException Trailing data

the table has a created_at field which is a postgres timestampz field i.e timestamp with timezone I guess.

and even if I access the field via $column->created_at

it's throwing that error.

Upvotes: 0

Views: 1162

Answers (1)

Maraboc
Maraboc

Reputation: 11093

Try to add getDateFormat in your Models to override the default format :

protected function getDateFormat()
{
    return 'Y-m-d H:i:sO';
}

The method getDateFormat is protected in Laravel 5.5 and below, but in the 5.6 it's public and it's mentioned in the upgrade guide on the Eloquent section : enter image description here

Upvotes: 1

Related Questions