gii GridView 检索日期节点
先进行安装datepicker 插件
composer require kartik-v/yii2-widget-datepicker "@dev"
追加扩展
composer require kartik-v/yii2-field-range "*"
使用gii生成表单之后,添加所需要的字段
<?php
use kartik\date\DatePicker;
?>
[
'attribute' => 'create_time',
'filter' => DatePicker::widget([
'name' => 'create_time_start',
'value'=>\Yii::$app->request->get('create_time_start'),
'name2' => 'create_time_end',
'value2' => \Yii::$app->request->get('create_time_end'),
'type' => DatePicker::TYPE_RANGE,
'options' => ['placeholder' => '开始日期'],
'options2' => ['placeholder' => '结束日期'],
'pluginOptions' => [
'autoclose' => false,
'format' => 'yyyy-mm-dd',
'todayHighlight' => false
]
]),
'value' => function ($data) {
return $data->create_time;
},
]