Date saving incorrectly due to timezone issue


Hi All,

 

I have a form that is used in two different timezone which are two hours apart. TimeZone 1 is two hours behind TmeZone2 and K2 server as well as SQL server is in TimeZone 2. So one user submitted a form from TimeZone 1 with a date as 02/01/20*personal details removed*:;59:00 PM but it is saved in the SQL as 03/01/20*personal details removed*:59:00 AM due to the timezone difference. How can I fix this issue? Using string? Any other option is there?

 

Regards,

Madhu


3 replies

Hello,

 

You should always save time as server time or you need to save wich time zone all clients are using.

Are all Client's in same time zone? Then it is easiest to set the server time zone to that one.

 

If not you should still save with server time zone then if you want client to see their time you could set it with javascript inside an expression.

 

example

<script>var date = new Date([MyDateString] + ' GMT'); //GMT being server timezone
date.toString(); //Will give date with client timezone.</script>

 

Hope this helps

/Björn

 

Good day madhu_hari


 


Please see the following. I hope they will help.


“Date saving incorrectly”: https://community.k2.com/t5/General/Date-saving-incorrectly/td-p/104599,


“Write to db using my current timezone settings”: https://community.k2.com/t5/K2-Five/Write-to-db-using-my-current-timezone-settings/m-p/113637#M4526.


 


Best,


Sunrise

Hi Madhu,


 


Are you using a calendar control for the date? If yes kindly check the below 


 


Date/Time value is being converted to the user's local timezone if smartforms was accessed on a different timezone than the K2 server. When it is saved into the database, the K2 server converts the value to the server's timezone. This is an expected behavior.


 


 


Kindly checkout the below link for more details on it


https://help.k2.com/support-services/kbt135043


 


Hope this helps


 


Cheers,


Kate

Reply