Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yii2: Correct Way to use Jui DatePicker

My Jui Date Time Picker was working perfectly, I am not sure if I have made any changes in config anywhere, but now the date-picker field is showing the format as if it is asking for time with the 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 config the relevant code for dates is like

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

Now I am trying to enter the date I am getting the field like 12/07/2014: and colon after the field as if I need to add the time part, where from it is coming, I couldn't find.

date-picker

like image 918
Pawan Avatar asked Oct 19 '22 16:10

Pawan


1 Answers

Recently I ran into the same problem.

dateFormat is no longer the part of clientOptions and should be specified like that:

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

Alternative in ICU format:

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

See official docs for $dateFormat property.

like image 172
arogachev Avatar answered Oct 22 '22 17:10

arogachev