datetime picker widget

I tried installing this widget github/kartik-v/yii2-widget-datetimepicker on my first yii program. It is a datetime picker which you can easily input the date and time. I successfully installed it and no errors at my code but I noticed that whenever I save the form after getting the date it doesn’t update the date it’s still:

Date 0000-00-00 00:00:00

Here’s my _form code




    <?= $form->field($model, 'date')->widget(

                    DateTimePicker::className(), [

                        'name' => 'datetime',

                        'options' => ['placeholder' => 'Select rendering time ...'],

                        'convertFormat' => true,

                        'pluginOptions' => [

                        'format' => 'yyyy/dd/mm hh:ii:ss',

                        'startDate' => '01-Jul-2017 12:00 AM',

                        'todayHighlight' => true

                    ]


        ]); ?>

I actually don’t know what’s wrong, the data types in the database was set into DATETIME.

Not sure, but I think you don’t need the ‘name’=> part if you are using it as a form widget.

remove the name option from options array that could be the reason


<?= $form->field($model, 'date')->widget(

                    DateTimePicker::className(), [

                        'options' => ['placeholder' => 'Select rendering time ...'],

                        'convertFormat' => true,

                        'pluginOptions' => [

                        'format' => 'yyyy/dd/mm hh:ii:ss',

                        'startDate' => '01-Jul-2017 12:00 AM',

                        'todayHighlight' => true

                    ]


        ]); ?>