Reputation: 355
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
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 :
Upvotes: 1