use yii\behaviors\TimestampBehavior; use yii\db\ActiveRecord; class Post extends ActiveRecord { public function behaviors() { return [ TimestampBehavior::class, ]; } }
public function behaviors() { return [ [ 'class' => TimestampBehavior::class, 'updatedAtAttribute' => 'modified_at', ], ]; }In this example, the TimestampBehavior is set to update the "modified_at" field instead of the default "updated_at" field. This is useful if you want to customize the timestamp field name. The Yii TimestampBehavior is part of the Yii2 framework library.