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

AlexanderKim's avatar

Setting custom date results an error

From L5.6 documentation, i can change default date format in a model:

class Flight extends Model
{
    /**
     * The storage format of the model's date columns.
     *
     * @var string
     */
    protected $dateFormat = 'd.m.Y';
}

However, when i do this, i'm getting this error:

The separation symbol could not be found Unexpected data found. Trailing data

Do i need to update my schema? I am using currently:

$table->timestamps();

0 likes
3 replies
Snapey's avatar

Why do you want to do this? what problem are you trying to solve?

BishoyWagih's avatar

for created_at and updated_at fields they are already carboon instance, so you can anywhere in you project call them with

 $post->created_at->format('d.m.Y');

Or

if you want to make the default format for them you can create mutator for each one of them like

public function getCreatedAtAttribute($date)
{
    return Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $date)->format('d.m.Y');
}

public function getUpdatedAtAttribute($date)
{
    return Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $date)->format('d.m.Y');
 }

Please or to participate in this conversation.