Wrong time zone in the Web-app

Hi, guys,

I have a little problem that I am not sure how to solve.

I have the following code in my web app


Dim d As New Date

s = s + str(d.ShortDate) + "  " +  str(d.ShortTime) + EndOfLine + EndOfLine + EndOfLine

When I just Run the code, the time is displayed correctly (for example, 2:50 pm)

When I deploy the application, the time is five hours later (for example, 7:50 pm).

What is the way to have this discrepancy fixed?

Thank you in advance,

Val

This is likely the time difference for your server for where it is located. If you have control over it you could change its timezone to that which you require.

Use Session.GMTOffset to adjust times to the user’s timezone.

What time zone do you want to use, the server or that of the user who visits your site?

This will set the Hashtag with “TZ:” followed by the time offset in minutes. For instance in France where I am with daylight saving time, it is -120.

You get this value with the Session. HastagChanged event, and after a split around “TZ:” you have your user offset from UTC.

If you are familiar with Websdk you can do it more elegantly, but it goes beyond the scope of this discussion.

Sub Shown() Handles Shown Dim JS as string js = js + "var offset = new Date().getTimezoneOffset();" js = js + "location.hash = 'TZ:'+offset" self.ExecuteJavaScript(js) End Sub

HI, everyone,

Thank you for the advice. I am trying to find out how to implement the solutions you have suggested.

Val

It should be as simple as

dim d as New Date
d.GMTOffset = Session.GMTOffset

[quote=454607:@Tim Hare]It should be as simple as

dim d as New Date d.GMTOffset = Session.GMTOffset [/quote]

Much simpler indeed :smiley: