How to change default timestamp fields name in Laravel

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.

Answers 1
  • 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