datepicker yii2 kartik wrong format

3.8k views Asked by At

I have a problem with the kartik datetime picker.

The value that has to be entered gets scrambled in the input, following screenshot probably tells it all:

screenshot scrambled input

I simply followed the demo code:

 <?php
   use kartik\datetime\DateTimePicker;
   echo '<label>Start Date/Time</label>';

   echo DateTimePicker::widget([
        'name' => 'startdatetime',
        'options' => ['placeholder' => 'Select operating time ...'],
        'convertFormat' => true,
        'pluginOptions' => [
            'format' => 'd-M-Y g:i A',
            'startDate' => '01-Mar-2014 12:00 AM',
            'todayHighlight' => true
         ]       
    ]);     
    ?>
1

There are 1 answers

0
Tony On BEST ANSWER

You are using php's data formatting characters. See plugin documentaion about correct date formatting. In your case instead of d-M-Y g:i A it should be dd-M-yyyy H:ii P