How to change created_at and updated_at column names in Laravel

You can easily change created_at and updated_at column names by overriding CREATED_AT and UPDATED_AT constants in your Eloquent model.

Example #Task Model

Let’s assume you have a model called Task and it has columns called createdAt and updatedAt. But Laravel tries to insert data created_at and udpated_at column by default. So in order to inform Laravel about our new columns just define constants in your eloquent model as shown below –

Now Laravel will use above defined columns instead of created_at and updated_at columns.

Here is Eloquent base model –

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.