Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

aarontharker's avatar

Trailing data {"exception":"[object] (Carbon\\Exceptions\\InvalidFormatException(code: 0): The separation symbol could not be found

I don't understand what is causing this issue. In my model, I have the membership_expiry cast as a datetime

protected $casts = [
        'membership_expiry' => 'datetime',
        'email_verified_at' => 'datetime',
        'created_at' => 'datetime',
        'updated_at' => 'datetime',
        'deleted_at' => 'datetime',
    ];

and in my function, I convert a UNIX timestamp received from an API call to a Carbon object but when I try to save that Carbon object to the database it throws this error. I have tried formatting it as a DateTime string ('Y-m-d H:i:s') or just saving it as the Carbon object in the raw.

$date = Carbon::createFromTimestamp(trim($payload['data']['object']['current_period_end']));
$user->membership_expiry = $date;

both ways throw this error.

0 likes
5 replies
tykus's avatar

What does the result of trim($payload['data']['object']['current_period_end']) look like?

aarontharker's avatar

@tykus 1765629141 - I have checked and it is not the Carbon::createFromTimestamp that is causing the issue it is the casting when I save it to the eloquent model. If I add a echo($date->format('d-m-Y')) it echoes the date correctly

Snapey's avatar
Snapey
Best Answer
Level 122

You sure you don't have a mutator in your model?

aarontharker's avatar

@Snapey Yep you got it, I knew there was an accessor to set the date format, I had forgotten there was also a mutator.

Please or to participate in this conversation.