PHP code example of zhuravljov / yii2-datetime-widgets

1. Go to this page and download the library: Download zhuravljov/yii2-datetime-widgets 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/ */

    

zhuravljov / yii2-datetime-widgets example snippets


<?= $form->field($model, 'attribute')->widget(DatePicker::class, [
    'clientOptions' => [
        'format' => 'dd.mm.yyyy',
        'language' => 'ru',
        'autoclose' => true,
        'todayHighlight' => true,
    ],
    'clientEvents' => [],
]) 

<?= $form->field($model, 'attribute')->widget(DateTimePicker::class, [
    'clientOptions' => [
        'format' => 'dd.mm.yyyy hh:ii',
        'language' => 'ru',
        'autoclose' => true,
    ],
    'clientEvents' => [],
]) 

<?= $form->field($model, 'actual_time')->widget(DateRangePicker::class, [
    'clientOptions' => [
        'locale' => [
            'format' => 'YYYY-MM-DD',
            'separator' => ' - ',
        ],
        'ranges' => [
            'Today' => [
                new JsExpression('moment()'),
                new JsExpression('moment()'),
            ],
            'Yesterday' => [
                new JsExpression('moment().subtract(1, "days")'),
                new JsExpression('moment().subtract(1, "days")'),
            ],
        ],
    ],
    'clientEvents' => [],
])