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

PaulDiamant's avatar

Unable to set default date mutation

When I try the following in my model, it works as it's the default format.

protected $dateFormat = 'Y-m-d H:i:s';

However when I make the slightest change to it:

protected $dateFormat = 'Y-m-d H:i';

The above won't work and throw me the following error: The separation symbol could not be found Unexpected data found. Unexpected data found. Trailing data (View: D:\WampServer\www\resources\views\pages\profile.blade.php)

0 likes
3 replies
dmeganoski@gmail.com's avatar
Level 4

You have not given very much information. When are you getting this error? Is it when you try to save a record or when you try to display the record?

Chances are, you have already saved records in your database in the old format, and by changing the model's format without changing the existing records, it's going to have issues when it tries to format the old values.

1 like
PaulDiamant's avatar

That was my problem, trying to display the date while saved data has been saved with the old format. Thank you.

Please or to participate in this conversation.