brussens/yii2-datetimepicker-widget

Bootstrap 3 DateTimePicker widget for Yii2.

Installs: 7 100

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 2

Open Issues: 0

Type:yii2-extension

1.2.0 2018-09-25 18:23 UTC

This package is auto-updated.

Last update: 2024-10-15 01:38:53 UTC


README

Latest Stable Version Total Downloads License

Install

Either run

php composer.phar require --prefer-dist brussens/yii2-datetimepicker-widget "*"

or add

"brussens/yii2-datetimepicker-widget": "*"

to the require section of your composer.json file.

Options

Base usage:

use brussens\datetimepicker\Widget as DateTimePicker;

echo $form->field($model, 'attribute')->widget(DateTimePicker::className());

Advanced usage

use brussens\datetimepicker\Widget as DateTimePicker;

echo $form->field($model, 'attribute')->widget(DateTimePicker::className(), [
    'format'=>'DD-MM-YYYY HH:mm:ss',
    'clientOptions' => [
        'locale' => 'ru', //If you do not want to use auto-detection
        'icons' => [
            'time' => 'el-icon-time',
            'date' => 'el-icon-calendar',
            'up' => 'el-icon-chevron-up',
            'down' => 'el-icon-chevron-down',
        ],
        'useSeconds' => true,
        'useCurrent' => true,
        'sideBySide' => true
    ],
]);

Range usage (experimentally)

use yii\grid\GridView;
use brussens\datetimepicker\RangeWidget;

GridView::widget([
    'dataProvider' => $dataProvider,
    'filterModel' => $model,
    'columns' => [
        //... some columns
        [
            'filter' => RangeWidget::widget([
                'model' => $model,
                'attribute' => 'date_from',
                'attributeTo' => 'date_to'
            ]),
            'attribute' => 'created_at',
            'format' => 'datetime',
        ],
        ['class' => 'yii\grid\ActionColumn'],
    ],
]);

Profit