When I try to change the default format of the created_at field in my resource model, I get the following error:
{ "error":{ "type":"InvalidArgumentException", "message":"Unexpected data found. Unexpected data found. The separation symbol could not be found Unexpected data found. A two digit second could not be found", "file":"\/var\/www\/html\...vendor\/nesbot\/carbon\/src\/Carbon\/Carbon.php", "line":359 } }
Here is the code that caused the error above:
$tile = Resource::with('comments, ratings')->where('resources.id', '=', 1)->first(); $created_at = $tile->created_at; $tile->created_at = $created_at->copy()->tz(Auth::user()->timezone)->format('F j, Y @ g:i A');
If I remove ->format('F j, Y @ g:i A') from the above code, it works fine, but not in the format I want. What is the problem? I have an almost identical code elsewhere in my application and it works without errors.
UPDATE: Using setToStringFormat('F j, Y @ g:i A') does not raise an error, but returns null .
source share