Skip to main content


 

Symptoms

 


There are 2 users, who live in different time zones. Let’s keep it simple User 1 – UTC 1, User 2 – UTC 2.
SQL server is situated in UTC 1. The calendar control is mapped to a date field in SQL.
So User 2 saves the date for example 19/11/2014 on a form. But when User 1 is opening the form, he sees 18/11/2014. It happens because the date should be actually saved as 19/11/2014T00:00:00, but it is saved as 18/11/2014T23:00:00.

Using the date column in SQL is the same. So it does not matter. I saw one company writing a custom calendar control, which deals with the problem with the help of javascripts. But I have a working application with lots of forms and views. Is there a workaround for this?

 

 

Diagnoses

 


See resolution
 

 

Resolution

Unfortunately, there is no quick workaround. The only way I can see this working is if the SQL server and the K2 server are in the same time zone, but even then the current default calendar control on SmartForms would return the user's current time zone and save that in K2 SQL DB (with an offset of UTC 1 or 2).

A temporary workaround for this can be saving the date/time value as a string. This way, there should not be any conversion when saved and read from the DB. Although this stopped conversion server side, the conversion happened on the control still. Because of this, it was suggested that the client use a custom control. This way, we will not convert client or server side and you can save the date as is."

Now for the work-arounds that can be applied before this feature gets implemented:
1. As a temporary work-around, I suggest that the users facing this issue set their regional time zones to match that of the server time zone. I understand that this is not always viable, since there are many users
2. Due to point 1, the client can create a custom control that can achieve this. This custom control would NOT perform the conversion that is being seen by the client.
2.1 Take the current calendar control as a sample, and strip the conversion that is done (as this is on control level)
2.2 The solution that can be currently used, would be to create the custom control and implement it into K2 smartforms. If the client is happier to take this route, then here are a few links that can assist in terms of giving an example on how to create such a control:

 

 

 

K2 Knowledge Center - Building custom controls for K2 smartforms (video)

 

K2 smartforms Developers Reference

 

K2 Community Market

There should be a new feature in K2 SmartForms Calendar Control  which will address this issue by allowing to disable the auto-conversion of date time field to local time zone. At the moment it is preliminary planned for implementation in 4.7 release.

 

 



 
Be the first to reply!

Reply