Yii2: the right way to use Jui DatePicker

My Jui Date Time Picker worked just fine, I'm not sure I made any configuration changes anywhere, but now the date picker shows the format as if it were asking for a time with a date.

This is my code for the date field:

<?= $form->field($model, 'joining_date')->widget(DatePicker::className(),
                    ['clientOptions' =>[
                        'dateFormat' => 'dd-mm-yyyy',
                        'showAnim'=>'fold',
                        'changeMonth'=> true,
                        'changeYear'=> true,
                        'autoSize'=>true,
                         'showOn'=> "button",
                         'buttonImage'=> "images/calendar.gif",
                        'htmlOptions'=>[
                        'style'=>'width:80px;',
                        'font-weight'=>'x-small',
                        ],]]) ?> 

in my web.php configuration the corresponding code for dates is similar to

'formatter' => [
        'defaultTimeZone' => 'UTC',
        'timeZone' => 'Asia/Kolkata',
        'dateFormat' => 'php:d-m-Y',
        'datetimeFormat'=>'php:d-M-Y H:i:s'
        ],

Now I'm trying to enter the date the field was received, like 12/07/2014: and the colon after the field, as if I need to add the temporary part, where it comes from, I could not find.

date picker

+4
source share
3 answers

I recently ran into the same problem.

dateFormatis no longer part clientOptionsand should be indicated as follows:

<?= $form->field($model, 'joining_date')->widget(DatePicker::className(), [
    'dateFormat' => 'php:d-m-Y',
] ?>

ICU:

'dateFormat' => 'dd/MM/yyyy',

. $dateFormat.

+5

... Yii ( YII::)) .... - !!!

 'formatter'=>[
            'class'=>'yii\i18n\Formatter',
            //'dateFormat' =>'MM/dd/yyyy',
            'dateFormat' => 'php:d M Y',
            'datetimeFormat' => 'php:d-M-Y H:i:s',
            'timeFormat' => 'php:H:i:s',

        ],


use yii\jui\DatePicker; 

<?php echo $form->field($ShipmentTypeForm, 'shipmendate')->widget(DatePicker::className(), [
      'options' => ['class' => 'form-control input-sm','readOnly'=>'readOnly'],]); ?>
0

Alternatively use Bootprap datepicker. You just need to include the appropriate JS file and call something like this:

<?= $form->field($model, 'inputName', ['inputOptions'=>['class'=>'form-control datepicker']])->textInput() ?>
-1
source

All Articles