PHP code example of brussens / yii2-datetimepicker-widget

1. Go to this page and download the library: Download brussens/yii2-datetimepicker-widget 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/ */

    

brussens / yii2-datetimepicker-widget example snippets


use brussens\datetimepicker\Widget as DateTimePicker;

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

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
    ],
]);

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'],
    ],
]);

php composer.phar