yii2 - use TimestampBehavior to autmatically set datetime values of created_at and updated_at

yii2
voted: 3
vote
php yii2 activerecord datetime

TimestampBehavior to autmatically set datetime values of created_at and updated_at. If fields have other name than default, names can be overwite

<?
public function behaviors() {
        return [
            [
                'class' => TimestampBehavior::className(),
                // if fields have different names they can be defined in following lines
                //'createdAtAttribute' => 'create_time',
                //'updatedAtAttribute' => 'update_time',
                'value' => new Expression('NOW()')
            ],
        ];
    }
?>
working url: not entered
version: 2
Leave a Comment:
Characters left:

Added: 14 August 2016 7:44 am

It works, thx.