Why do you want to change the format they are stored ?
When they are retrieved, Carbon objects are returned. You can format them in any way you want.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello, I try to customize the Eloquent timestamps format of 'created_at' and 'updated_at' by doing so in my model:
public function setCreatedAtAttribute($date)
{
return $this->attributes['created_at'] = $date->format('d.m.Y H:i:s');
}
and in the same fashion for updated_at.
This works fine on Insert rsp. on create a new record but on update these methods are not called, ergo updated_at is stored in the default format.
Does somebody know how to save the update_at in a custom format on update?
@alexanderhempel If you want to use this format for all the timestamps of given model, override this method:
// Your model
protected function getDateFormat()
{
return 'd.m.Y H:i:s';
}
It means, that all the timestamps will be saved and also shown this way - no need for set/get mutators.
Otherwise you get yourself 'a bit' of trouble:
1. calling $model->updated_at will throw error (because Eloquent expects different format)
2. You need to override methods for update or turn off the timestamps, so Eloquent won't try to set freshTimestamp and so on, and so forth (again, Eloquent is going to parse the date using its default format)
Generally I would suggest changing the column to standard timestamp, instead of what you have now.
Please or to participate in this conversation.