PHP code example of sadi01 / yii2-daterangepicker

1. Go to this page and download the library: Download sadi01/yii2-daterangepicker library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sadi01 / yii2-daterangepicker example snippets


<?= $form->field($model, 'date_range')->widget(dateRangePicker::classname(),[
	'options'  => [
		'drops' => 'down',
		'placement' => 'right',
		'opens' => 'right',
		'language' => 'fa',
		'jalaali'=> true,
		'showDropdowns'=> true,
		'singleDatePicker' => false,
		'useTimestamp' => true,
		'locale'=> [
			'format'=> 'jYYYY/jMM/jDD'
		],
	],
	'htmlOptions' => [
		'class'	=> 'form-control',
		'id' => 'date_range',
		'autocomplete' => 'off'
	]
]);


<?= $form->field($model, 'from_date')->widget(dateRangePicker::classname(),[
	'options'  => [
		'format' => 'jYYYY/jMM/jDD',
		'viewformat' => 'jYYYY/jMM/jDD',
		'drops' => 'down',
		'placement' => 'right',
		'opens' => 'right',
		'language' => 'fa',
		'jalaali'=> true,
		'showDropdowns'=> true,
		'singleDatePicker' => false,
		'useTimestamp' => true,
		'locale'=> [
			'format'=> 'jYYYY/jMM/jDD',
			'jalaali' => true,
			'separator'=> ' - ',
			'applyLabel'=> Yii::t('yii', 'Apply'),
			'cancelLabel' => Yii::t('yii', 'Cancel'),
			'fromLabel' => Yii::t('yii', 'From'),
			'toLabel' => Yii::t('yii', 'To'),
			'customRangeLabel' => 'Custom',
			'daysOfWeek'=> [
				'یک',
				'دو',
				'سه',
				'چهار',
				'پنج',
				'جمعه',
				'شنبه',
			],
			'monthNames'=> [
				'فروردین',
				'اردیبهشت',
				'خرداد',
				'تیر',
				'مرداد',
				'شهریور',
				'مهر',   
				'آبان',
				'آذر',
				'دی',
				'بهمن',
				'اسفند',
			],
			'firstDay' => 6
		],
	],
	'htmlOptions' => [
		'class'	=> 'form-control',
		'id' => 'from_date',
		'autocomplete' => 'off',
	]
]);


<?= $form->field($model, 'date_time_range')->widget(dateRangePicker::classname(),[
	'options'  => [
		'drops' => 'down',
		'placement' => 'right',
		'opens' => 'left',
		'language' => 'fa',
		'jalaali'=> true,
		'showDropdowns'=> true,
		'singleDatePicker' => false,
		'useTimestamp' => true,
		'timePicker' => true,
		'timePicker24Hour' => true,
		'timePickerSeconds' => true,
		'locale'=> [
			'format' => 'jYYYY/jMM/jDD HH:mm:ss',
		],
	],
	'htmlOptions' => [
		'class'	=> 'form-control',
		'id' => 'date_time_range',
		'autocomplete' => 'off',
	]
]);


<?= $form->field($model, 'from_date_time')->widget(dateRangePicker::classname(),[
	'options'  => [
		'drops' => 'down',
		'placement' => 'right',
		'opens' => 'left',
		'language' => 'fa',
		'jalaali'=> true,
		'showDropdowns'=> true,
		'singleDatePicker' => true,
		'useTimestamp' => true,
		'timePicker' => true,
		'timePicker24Hour' => true,
		'timePickerSeconds' => true,
		'locale'=> [
			'format' => 'jYYYY/jMM/jDD HH:mm:ss',
		],
	],
	'htmlOptions' => [
		'class'	=> 'form-control',
		'id' => 'from_date_time',
		'autocomplete' => 'off',
	]
]);


<?= $form->field($model, 'date_range')->widget(dateRangePicker::classname(),[
	'options'  => [
		'minDate' => '1399/09/09',
		'maxDate' => '1401/01/01',
		'drops' => 'down',
		'placement' => 'right',
		'opens' => 'right',
		'language' => 'fa',
		'jalaali'=> true,
		'showDropdowns'=> true,
		'singleDatePicker' => false,
		'useTimestamp' => true,
		'locale'=> [
			'format'=> 'jYYYY/jMM/jDD'
		],
	],
	'htmlOptions' => [
		'class'	=> 'form-control',
		'id' => 'date_range',
		'autocomplete' => 'off'
	]
]);