Solved

Write to db using my current timezone settings

  • 18 November 2019
  • 5 replies
  • 63 views

The server hosting my db is in another timezone (Belgium) while the users for the form I have created are in Singapore. The form has a date submitted field on it. Is it possible so that when the user submits the form, the date stamp written on the database is based from the user's timezone? 

 

The first image below shows the user submitted the form 5:24PM (Singapore Time). Is there a way to do it so that the database also has 5:24PM on it and not 10:24AM?

14956iB80AD5F21D4E832A.png

 

I have tried using the Add hours rule by adding 7. But when Daylight Savings Time begins, this rule would not be accurate anymore and would have to be changed.

I also can not change the time zone of the server as there are users in Belgium.

 

Any help would really be helpful.

icon

Best answer by KagisoMasha 18 November 2019, 15:21

View original

5 replies

Good day  @AaronAbe 

 

May you please see the following:

Calendar Control displays a different Date value in different Time Zones: https://help.k2.com/support-services/kbt135043,

“Calendar control changes date with timezones”: https://community.k2.com/t5/K2-blackpearl-Articles/Calendar-control-changes-date-with-timezones/ta-p/74068?nobounce, 

Calendar Control: https://help.k2.com/onlinehelp/k2five/userguide/5.3/default.htm#Create/K2Designer/Controls/Calendar/CalendarControl.htm.

 

Best,

Sunrise

Badge +7

Hello

 

AaronAbe,

I have done a small reproduction using radio buttons with calendar picker control to choose between times. This here changes to the time zone of your choice every time you  submit.

 

  1. In your view just below Registration Status. Add the radio but group. Label the 1st radio button Singapore and the 2nd Radio Button Belgium.
  2. In Layout page, Under the category heading, navigate to your Data Source heading under the properties tab on your left. Click type ellipsis and choose Use a static list of values in the control. Click List items ellipsis and add value and display. In your case you will add Singapore and Belgium separately. Click ok and ok again to return to the layout section.

While still in the Layout page. Select date time control, properties, click format ellipsis and select User settings radio button, next to Language/Regional Settings

Rules

3. Under conditions tab, type “contains” and select “a control contains a specific value”. Click on it. Select the name radio button list control and select value “Singapore”.

 

3.1. Select the Actions tab, type “properties” and select “Set a control’s properties” and select the Date time calendar control . Click configure, change display time zone to be (UTC+08:00) Beijing, Chongqing, HongKong, Urumqi. Click ok to return to your rules.

 

3.2. Repeat step 3 and 3.1 for Belgium

 

3.3. While still in your rules, In the conditions tab, type “advanced” and select “an advanced condition is true”, select the date time calendar control. click configure, in general , select the “no” radio in enabled.

 

When selecting the time zone you want, it should change with every submission change made. My literature is not up to par, but these are steps to a functionality that is working.

 

@AaronAbe I have also attached screen shots to the rules to aid with this reproduction on the right of the screen.

 

I hope you manage.

 

 

 

 

 


Good day AronAbe,


 


Please see the following community post: https://community.k2.com/t5/K2-Blackpearl-Forum-Posts/How-to-change-K2-system-time-zone/td-p/66634


 


Kind regards


Dumisani

Hi  @AaronAbe ;


 


In additional to @Dumisani 's refferal, Should there be any alteration of some sort feel free to dive & drill into this external doc perhaps it could be very helpful  to change the whole sql time zone(https://www.inmotionhosting.com/support/website/databases/how-to-change-mysql-server-time-zone/) follow the prompts and goodluck.


 


Kind regards;


Widson.


 

thanks  @KagisoMasha and everyone. 

@KagisoMasha I followed slightly your suggestion. I did not need radio buttons as my user did not need to choose different timezones. Sorry if I may not have been clear in the problem statement. They are always at Singapore time zone and I needed to figure out a way to ensure that when the record was written on the database, it was still reflecting the Singapore Time zone and not the server's Belgium time zone. I also could not change the server time zone itself as there are also a different group of users located in Belgium but from a different deparment that were using their own forms.

However, your input did help point me to the right direction. I created a rule to set the property of the control when it loaded. What was weird was when I set that to UTC +8 for Singapore time, it still did not save the time correctly. However, when i set the control's property to UTC +1 to match Belgium's timezone it was now both displaying on the form Singapore's timezone plus it was writing on the database using Singapore's timezone as well. I'm not sure why this is behaving this way but hey it fixed it so I'm good with it.

 

thanks again.

Reply