timeAttributes) && $this->timeAttributes = [$this->createdAtAttribute => $this->createdAtAttribute, $this->updatedAtAttribute => $this->updatedAtAttribute] ; } public function events() { return [ SearchEvent::BEFORE_SEARCH => 'beforeSearch' ]; } public function beforeSearch($event) { /** @var $event \backend\components\search\SearchEvent */ foreach ($this->timeAttributes as $filed => $attribute) { if($attribute !== null) $timeAt = $event->sender->{$attribute}; if( !empty($timeAt) ){ $time = explode($this->delimiter, $timeAt); if( $this->format === 'int' ){ $startAt = strtotime($time[0]); $endAt = strtotime($time[1]); }else{ $startAt = $time[0]; $endAt = $time[1]; } $event->query->andFilterWhere([ 'between', $filed, $startAt, $endAt ]); } } } }