user4839727
user4839727

Reputation:

Carbon 'InvalidArgumentException' with message 'Trailing data' when overriding $dateFormat attribute

In order to force my Eloquent Models to output dates in unix-timestamp (not string formatted) when serialized with toJson() method, I have overridden the $dateFormat attribute as the following:

$dateFormat = 'U;

This seems to be the recommended way to change how Date attributes are outputted. (Please check this question). But I'm getting the following errors by doing so.

Fatal error: Uncaught exception 'InvalidArgumentException' with message 'Trailing data' in ...\vendor\nesbot\carbon\src\Carbon\Carbon.php on line 425

Followed by this one:

InvalidArgumentException: Trailing data in ...\vendor\nesbot\carbon\src\Carbon\Carbon.php on line 425

What am I doing wrong?

Upvotes: 3

Views: 1125

Answers (1)

nfinzer
nfinzer

Reputation: 1

Well you did not close your string literal for one thing.

Upvotes: 0

Related Questions