J
J
John-Galt2017-02-08 02:39:42
Yii
John-Galt, 2017-02-08 02:39:42

In yii2, how is it customary to update created_at and updated_at fields that are stored in integer?

In yii2, how is it customary to update created_at and updated_at fields in database tables that are stored in integer?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
John-Galt, 2017-02-08
@John-Galt

Found. Who needs:

/**
     * @inheritdoc
     */
    public function behaviors()
    {
        return [
            'timestamp' => [
                'class' => TimestampBehavior::className(),
                'attributes' => [
                    ActiveRecord::EVENT_BEFORE_INSERT => ['created_at', 'updated_at'],
                    ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at'],
                ],
            ],
        ];
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question