wodrow 2017-02-08 10:42:43 3836次浏览 2条评论 1 0 0

QQ截图20170208103557.png

废话少说,放代码

view:

[
    'attribute'=>'join_at',
    'format' => ['date', 'php:Y-m-d H:i:s'],
    'filterType' => \kartik\grid\GridView::FILTER_DATE_RANGE,
    'filterWidgetOptions' =>([
        'model'=>$searchModel,
        'attribute'=>'join_at',
        'presetDropdown'=>TRUE,
        'convertFormat'=>true,
        'pluginOptions'=>[
            'format'=>'Y-m-d',
            'locale' => [
                'cancelLabel' => 'Clear',
                'format' => 'Y-m-d',
            ]
        ],
    ]),
],

SearchModal:

if ( ! is_null($this->join_at) && strpos($this->join_at, ' - ') !== false ) {
    list($start_date, $end_date) = explode(' - ', $this->join_at);
    $query->andFilterWhere(['between', 'join_at', strtotime($start_date), strtotime($end_date.' 23:59:59')]);
}
您需要登录后才可以评论。登录 | 立即注册