Skip to content

mitalcoi/yii2-datetime-widgets

 
 

Repository files navigation

Datetime widgets for Yii2

Installation

The preferred way to install this extension is through composer.

Add

"mitalcoi/yii2-datetime-widgets" : "dev-master"

to the require section of your application's composer.json file.

DatePicker

Demo from the bootstrap-datepicker plugin website.

Usage

use mitalcoi\widgets\DatePicker;
<?= $form->field($model, 'attribute')->widget(DatePicker::className(), [
    'options' => ['class' => 'form-control'],
    'clientOptions' => [
        'format' => 'dd.mm.yyyy',
        'language' => 'ru',
        'autoclose' => true,
        'todayHighlight' => true,
    ],
]) ?>

For more details, please check the bootstrap-datepicker plugin website.

DateTimePicker

Demo from the bootstrap-datetimepicker plugin website.

Usage

use mitalcoi\widgets\DateTimePicker;
<?= $form->field($model, 'attribute')->widget(DateTimePicker::className(), [
    'options' => ['class' => 'form-control'],
    'clientOptions' => [
        'format' => 'dd.mm.yyyy hh:ii',
        'language' => 'ru',
        'autoclose' => true,
    ],
]) ?>

For more details, please check the bootstrap-datetimepicker plugin website.

DateRangePicker

Demo from the bootstrap-daterangepicker plugin website.

Usage

use mitalcoi\widgets\DateRangePicker;
<?= $form->field($model, 'actual_time')->widget(DateRangePicker::className(), [
    'options' => ['class' => 'form-control'],
    'clientOptions' => [
        'ranges' => [
            'Today' => [
                new JsExpression('moment()'),
                new JsExpression('moment()'),
            ],
            'Yesterday' => [
                new JsExpression('moment().subtract("days", 1)'),
                new JsExpression('moment().subtract("days", 1)'),
            ],
        ],
        'format' => 'DD.MM.YYYY',
        'separator' => ' - ',
    ],
]) ?>

For more details, please check the bootstrap-daterangepicker plugin repo.

About

Datetime widgets for Yii2

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 98.0%
  • PHP 2.0%