Datepicker subtracts a day

Hi, first post here,

I hope you guys can help me a little. I’m working on my first yii2 application and I just installed krajees datecontrol (im not allowed to link it right now)

And it’s working. As a visitor, I can choose a date and it gets stored in the database (in unixtime).

Code:


$form->field($model, 'myDateField')->widget(DateControl::classname(), [

                        'type'=>DateControl::FORMAT_DATE,

                        'ajaxConversion'=>true,

                        'saveFormat' => 'php:U',

                        'displayFormat' => 'php:d.m.Y',

                        'saveTimezone' => 'Europe/Amsterdam',

                        'displayTimezone' => 'Europe/Amsterdam',

                        'language' => 'de',

                       

                        'widgetOptions' => [

                            'pluginOptions' => [

                                'autoclose' => true

                            ]

                        ]

]);

After saving my object, I can validate the saved date:


select id, myDate,from_unixtime(myDate) from myTable order by id desc;

So I am sure that the correct date is saved. But, If I edit my object, there is a wrong date displayed, it’s always savedDate-1day.

my yii2-Settings should be correct too


'defaultTimeZone' => 'Europe/Amsterdam',

It would be great if someone could help me here,

ty!

Hi there and welcome to the forums.

If your values saved in the database are correct the its likely the third-party widget you using is messing up your date.

Hi,

thanks for your reply. I changed my database scheme from unixtimestamp to mysql-date, and the error is gone since then.