Yii Framework Forum: Date changed upon update - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Date changed upon update

#1 User is offline   ridz 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 27
  • Joined: 05-August 11

Posted 12 May 2018 - 12:47 AM

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
								
							]
						]
					]);
				?>



0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users