yii2-bootstrap-daterangepicker

This extension is a wrapper for Bootstrap Datepicker for Yii 2 Framework.
4 followers

Requirements

This extension requires Yii 2 Framework and Yii 2 Bootstrap extension.

Usage

// Include namespace
    use bburim\daterangepicker\DateRangePicker as DateRangePicker;
 
    // Define  ranges correctly
    $ranges = new \yii\web\JsExpression("{
                        'Today'        : [Date.today(), Date.today()],
                        'Yesterday'    : [Date.today().add({ days: -1 }), Date.today().add({ days: -1 })],
                        'Last 7 Days'  : [Date.today().add({ days: -6 }), Date.today()],
                        'Last 30 Days' : [Date.today().add({ days: -29 }), Date.today()],
                        'This Month'   : [Date.today().moveToFirstDayOfMonth(), Date.today().moveToLastDayOfMonth()],
                        'This Year'    : [Date.today().moveToMonth(0,-1).moveToFirstDayOfMonth(), Date.today()],
                        'Last Month'   : [Date.today().moveToFirstDayOfMonth().add({ months: -1 }), Date.today().moveToFirstDayOfMonth().add({ days: -1 })]
                    }");
 
    // Define empty callback fust for fun
    $callback = new \yii\web\JsExpression("function(){}");
 
    // Provide required parameters and render the widget
      echo DateRangePicker::widget([
            'callback' => $callback,
            'options'  => [
               'ranges' => $ranges,
               'locale' => [
                'firstDay' => 1
               ]
            ],
            'htmlOptions' => [
            'name'        => 'daterange',
            'class'       => 'form-control',
            'placeholder' => 'Select Date Range',
            'style'       => 'width:190px;',
            ]
        ]);

Installation

Via Composer:

php composer.phar require "bburim/daterangepicker"

Or download and install manually: https://github.com/bburim/daterangepicker/archive/master.zip

Resources

Github: https://github.com/bburim/daterangepicker

Composer Package: https://packagist.org/packages/bburim/daterangepicker

Total 1 comment

#16379 report it
zvik2004 at 2014/02/17 01:22am
Integration with form

Hi
Is there support in form object?
If so, can you please add example?
Thanks

Leave a comment

Please to leave your comment.

Create extension
Downloads
No downloadable files yet