core/behaviors/TimestampBehavior.php
public function beforeInsert($event)
    {
        foreach ($this->insert as $field) {
            $event->sender->$field = time();
        }
    }
public function beforeInsert($event)
    {
        foreach ($this->insert as $field) {
            $event->sender->$field = time();
        }
    }
public function beforeInsert ( $ event ) { foreach ( $ this -> insert as $ field ) { $ event -> sender -> $ field = time ( ) ; } }
Insert the timestamp for all provided fields.

@param \yii\base\Event $event Event object from Active Record.
Insert the timestamp for all provided fields .