Answer the question
In order to leave comments, you need to log in
What is the error of using TimeStampBehavior in Yii2?
Hello.
When creating a record and when updating, we log the time
return [
'timestamp' => [
'class' => TimestampBehavior::className(),
'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => 'created_at',
ActiveRecord::EVENT_BEFORE_UPDATE => 'updated_at',
],
'value' => function() { return date('U'); },
],
];
return [
'class' => TimestampBehavior::className(),
'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => ['create_time', 'update_time'],
ActiveRecord::EVENT_BEFORE_UPDATE => ['update_time'],
],
];
return [
TimestampBehavior::className(),
];
Answer the question
In order to leave comments, you need to log in
return [
'class' => TimestampBehavior::className(),
'createdAtAttribute' => 'created_at',
'updatedAtAttribute' => 'updated_at',
'value' => function () {
return date('Y-m-d H:i:s');
}
];
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question