This is the forum for the yii2-date-range extension for Yii framework 2.0.

This extension is a date range picker widget for Yii 2.0 using Bootstrap 3.x styles and preset date selection dropdowns and more.

Refer documentation and/or view a complete demo.

Hi Katik,

I had some problem to set the ranges,

I’ve tried

$datepicker = DateRangePicker::widget([



    'language'=>'it',             // from demo config

    'hideInput'=>true,           // from demo config

    'presetDropdown'=>true, // from demo config


        'format'=>'d/MM/YY',             // from demo config

        'separator'=>' - ',       // from demo config


		'ranges' => [

			"Oggi" => ["moment()", "moment()"],

			"Ieri" => ["moment().subtract('days', 1)", "moment().subtract('days', 1)"],

			"Mese Corrente" => ["moment().startOf('month')", "moment().endOf('month')"],

			"Mese Scorso" => ["moment().subtract('month', 1).startOf('month')", "moment().subtract('month', 1).endOf('month')"],




but seems the extension override my setting.

So I had to change the Inizializing pluginOption range list addind one more if before setting $this->pluginOptions[‘ranges’].


     * Initializes the pluginOptions range list


    protected function initRange()


        if ($this->presetDropdown) {

            $this->initRangeExpr = true;

            if (!isset($this->pluginOptions['ranges'])) // test ranges before set

	            $this->pluginOptions['ranges'] = [

	                Yii::t('kvdrp', "Today") => ["moment()", "moment()"],

	                Yii::t('kvdrp', "Yesterday") => ["moment().subtract('days', 1)", "moment().subtract('days', 1)"],

	                Yii::t('kvdrp', "Last {n} Days", ['n'=>7]) => ["moment().subtract('days', 6)", "moment()"],

	                Yii::t('kvdrp', "Last {n} Days", ['n'=>30]) => ["moment().subtract('days', 29)", "moment()"],

	                Yii::t('kvdrp', "This Month") => ["moment().startOf('month')", "moment().endOf('month')"],

	                Yii::t('kvdrp', "Last Month") => ["moment().subtract('month', 1).startOf('month')", "moment().subtract('month', 1).endOf('month')"],


            $this->pluginOptions['startDate'] = new JsExpression("moment().subtract('days', 29)");

            $this->pluginOptions['endDate'] = new JsExpression("moment()");


        if (!$this->initRangeExpr || empty($this->pluginOptions['ranges']) || !is_array($this->pluginOptions['ranges'])) {



        $range = [];

        foreach ($this->pluginOptions['ranges'] as $key => $value) {

            if (!is_array($value) || empty($value[0]) || empty($value[1])) {

                throw new InvalidConfigException("Invalid settings for pluginOptions['ranges']. Each range value must be a two element array.");


            $range[$key] = [static::parseJsExpr($value[0]), static::parseJsExpr($value[1])];


        $this->pluginOptions['ranges'] = $range;


There was some othe way?

One more question. How can I setup to have immediatly both rangelist and the two caledar as in the bootstrap example?

@J_jack_K if you want to configure your own ranges list, then set presetDropdown to false and then set your ranges. If presetDropdown is set to true, plugin will use the preset defaults inside.

But, if you want to use the presetDropdown as is, and just change the language, submit a translation using these instructions.

When using a rangeList, clicking the Custom Range option will show the DOUBLE CALENDAR.

You can read the documentation here or view a demo.

Hi Kartik,

yes presetDropdown to false works fine.


I know that Custom Range show the double calendare but I wolud like to have the double calenrad immediatly without click the custom range.



That’s how the plugin is defined by default. You can read and check details here. The reason probably is that selections of presets in the ranges, will automatically select a calendar range (so showing a calendar will not help in that case because its a preselected range).

However, in a custom range, you actually need to pick dates from the calendar. You can probably raise an enhancement request if needed with the plugin owner to see if it can be included.

Hi Kartik!

I installed the “kartik-v/yii2-date-range”: “dev-master”, but i’ve exception - Getting unknown property: kartik\daterange\DateRangePicker::language. Help please!