Date changed upon update


(Me) #1

Hi,

I have a form with a date input. The date input works well. The dates are shown and saved correctly in the database.

Example -

Date picked - 12 May 2018.

Once saved the date will be shown in the view as 12 May 2018 (correct date).

However, when I tried to update, the date shown on the form will be 11 May 2018 (wrong date).

Can someone help me to solve this issue? Thanks in advance.

The following is the date config in main.php




'datecontrol' =>  [

			'class' => '\kartik\datecontrol\Module',

			'displaySettings' => [

				Module::FORMAT_DATE => 'dd-MM-yyyy',

				Module::FORMAT_TIME => 'hh:mm:ss a',

				Module::FORMAT_DATETIME => 'dd-MM-yyyy hh:mm:ss a', 

			],

			'saveSettings' => [

				Module::FORMAT_DATE => 'php:U', // saves as unix timestamp

				Module::FORMAT_TIME => 'php:H:i:s',

				Module::FORMAT_DATETIME => 'php:Y-m-d H:i:s',

			],

			'displayTimezone' => 'Asia/Singapore',

			//'displayTimezone' => 'UTC',

			'saveTimezone' => 'Asia/Singapore',

			'autoWidget' => true,

			'autoWidgetSettings' => [

				Module::FORMAT_DATE => ['type'=>1, 'pluginOptions'=>['autoclose'=>true]], // example

				Module::FORMAT_DATETIME => ['dd-MM-yyyy'], // setup if needed

				Module::FORMAT_TIME => ['hh:mm:ss a'], // setup if needed

			],

		],




This is the code for the date field.




<?=	$form->field($model,'quote_dte')->widget(DateControl::classname(), [

						'type'=>DateControl::FORMAT_DATE,

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

						'saveFormat' => 'php:U',

						'ajaxConversion'=>true,

						'options' => [

							'pluginOptions' => [

								'todayHighlight' => true,

								'todayBtn' => true,

								'autoclose' => true

								

							]

						]

					]);

				?>