yii jui datepicker在更新页面上没有显示正确的日期

时间:2016-11-08 07:18:26

标签: php date yii2

我在我的表单中使用以下datepicker代码..日期在数据库中正确保存但在更新页面中日期在字段中显示为'01 .1970'但是当我更改并保存时,它正确存储在数据库中..但编辑时的字段显示始终为01.1970

<?= $form->field($model,'apartment_year_build')->widget(DatePicker::className(),[ 'dateFormat' => 'MM.yyyy', 'clientOptions' => [
                        'changeMonth' => true,
                        'yearRange' => '1989:2099',
                'changeYear' => true,
                        'firstDay' =>'1',
                        // 'showOn' => 'button',
                        // 'buttonImage' => 'images/calendar.gif',
                        // 'buttonImageOnly' => true,
                        // 'buttonText' => 'Select date' >

                    ],'options'=>['class'=>'form-control']]) ?>

1 个答案:

答案 0 :(得分:0)

如果你有01.1970这意味着mysql(或php?)处理错误的日期内容。 (1970年1月1日等同于零日期)

检查数据库是否正确保存了值。

如果你需要像02.2016这样的格式,你的格式应该是

    [ 'dateFormat' => 'php:m.Y',....