Yii2框架如何在数据表Model中自动设置时间戳?

已邀请:

zkbhj - 凯冰科技站长

赞同来自:

public function behaviors()
{
return [
[
'class' => TimestampBehavior::className(),
'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => ['created_at','updated_at'],
ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at']
],
'value' => function () {
return date('Y-m-d H:m:s');
},
],
];
}

要回复问题请先登录注册