Yii2-date-range example of use in a GridView?

Use in his project, kartik-v/yii2-date-range.

The question arose as to its proper use in a GridView?

I tried this:

Search:
...
 public function behaviors()
{
 return [
[
 'class' => DateRangeBehavior::className(),
 'attribute' => 'createTimeRange',
 'dateStartAttribute' => 'createTimeStart',
 'dateEndAttribute' => 'createTimeEnd',
]
];
}

 public function rules()
{
 return [
 [['id', 'card_id', 'card_type_id', 'balance', 'created_at', /*'expires_at',*/
 'corporative', 'barter', 'active', 'countNew', 'status'], 'integer'],
 [['user_id'], 'safe'],
 [['createTimeRange'], 'match', 'pattern' => '/^.+\s\-\s.+$/'],
];
}

 public function search($params)
{
...
 $query->andFilterWhere(['>=', 'expires_at', Date('Y-m-d 00:00:00', strtotime($this->createTimeStart))])
 ->andFilterWhere(['<', 'expires_at', Date('Y-m-d 00:00:00', strtotime($this->createTimeEnd))]);
...
}
...


View:
...
[
 'attribute' => 'createTimeRange',
 'value' => function ($model, $index, $widget) {
 return date('Y-m-d', strtotime($model->expires_at));
},
 //'format' => 'date',
 'width' => '20%',
 'filterType' => \kartik\grid\GridView::FILTER_DATE_RANGE,
 'filterWidgetOptions' => [
 'convertFormat' => false,
 'presetDropdown' => true,
 'pluginOptions' => [
 'format' => 'Y-m-d',
 'autoclose' => true,
]
]
],
...


As a result, nothing is filtered. I would like to see an example of how it should look
June 26th 19 at 14:14
2 answers
June 26th 19 at 14:16
What does DateRangeBehavior?

Examples of using the DateRangePicker is complete on demos.krajee.com/date-range#usage . In particular, filtering is more convenient to use the example "Advanced configuration using separate start and end attributes to store information". Further filtering is no different from any other field.
June 26th 19 at 14:18
Good morning.
In the GridView you can use this:
[
 'attribute' => 'created_at',
 'format' => 'datetime',
 'filter' => DatePicker::widget([
 'model' => $searchModel,
 'attribute' => 'date_from',
 'attribute2' => 'date_to',
 'type' => DatePicker::TYPE_RANGE,
 'separator' => '-',
 'pluginOptions' => ['format' => 'yyyy-mm-dd']
])
 ],

Find more questions by tags YiiPHP