How to change default timestamp fields name in Laravel

Created at 07-Jan-2022 , By samar

How to change default timestamp fields name in Laravel

Through the use of the programming language, we will work together to solve the "How to change default timestamp fields name in Laravel" puzzle in this lesson.

Sometimes you have to change the default timestamp field name in Laravel. In case you have a non-Laravel database with created_time and updated_time columns then you can use this code snippet to solve the problem.
  • Change default timestamp fields

    class Post extends Model
    {
        const CREATED_AT = 'created_time';
        const UPDATED_AT = 'updated_time';
    }
    

    If your timestamp columns (created_at , updated_at) are named differently, in case you are working with a non-Laravel database and you have columns created_time and updated_time in the table. You can specify them in the model, too.

Back to code snippet queries related laravel

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Buy Me A Coffee

Don't forget to share this article! Help us spread the word by clicking the share button below.

We appreciate your support and are committed to providing you valuable and informative content.

We are thankful for your never ending support.