class User method: extends Model public {$timestamps = false; / / public static function boot closed automatic maintenance (parent:): boot ({); # only add created_at add updated_at static:: creating (function ($model) {$model-> created_at = $model-> (freshTimestamp); //$model-> updated_at = $model-> (freshTimeStamp);});}} 
 where a pit: create a record using the Create method returns the value of created is this: "created_at": {"date": "2017-09-27 13:47:12.000000", "timezone_type": 3, "timezone": "Asia/Shanghai"}, and is not in the imagination of "created_at": "2017-09-27 13:49:39", "/pre > 

 class User two: extends Model const {UPDATED_AT = null; / / update_at null //const CREATED_AT set}
 = null; here are pit: use destroy to remove wrong Missing argument 2 for IlluminateDatabaseEloquentModel: setAttribute (delete): the use of wherein is not affected, does not affect the 

 class User three: extends Model {/ / override the setUpdatedAt method public function setUpdatedAt ($value) {/ / Do nothing.} //public function setCreatedAt ($value) //{/ / Do nothing. 

 class: Method four User extends Model setUpdatedAt public function {/ / rewriting method setUpdatedAtAttribute ($value) {/ / Do nothing.} //public function setCreatedAtAttribute ($value) //{/ / Do nothing. 


in Migration can also be set (specific never tried, see in other articles in the

 class CreatePostsTable) extends Migration function (up) {public {Schema:: create ('posts', function (Blueprint $table) {$table-> timestamp ('created_at') -> default (DB:: raw ('CURRENT_TIMESTAMP'));}); several methods of}

this laravel ORM created_at is a small open only to share with you all the contents to summarize, I hope to give you a A reference, and also hope that you can support a lot of scripting home.

: articles you may be interested in:

This paper fixed link: | Script Home | +Copy Link

Article reprint please specify:A summary of several methods for laravel ORM to open only created_at | Script Home

You may also be interested in these articles!