locked
Client-side time-zone RRS feed

  • Question

  • User1823730432 posted

    Hi

    I have client-side code that gets the client date(date-time)

     

    And then use this to get time-zone information about the client and the server

     

        2 Public Function getTimeZone(ByVal value As Date) As String

        3 

        4         Dim unclearDate As Date = value

        5         Dim zone As String

        6         zone = (TimeZoneInfo.Local.DisplayName + unclearDate.ToString + IIf(TimeZoneInfo.Local.IsAmbiguousTime(unclearDate), "", " "))

    7                            zone += "<br />"

    8         zone += (TimeZoneInfo.Local.DisplayName + unclearDate.ToString +   IIf(TimeZoneInfo.Local.IsDaylightSavingTime(unclearDate), "", " "))

        9         zone += "<br />"

       10         If TimeZoneInfo.Local.IsAmbiguousTime(unclearDate) OrElse TimeZoneInfo.Local.IsDaylightSavingTime(unclearDate) Then

       11             zone += (unclearDate.ToString + TimeZoneInfo.Local.DisplayName)

       12         End If

       13 

       14 

       15         'Dim thisTime As Date = value

       16         'Dim zone As String

       17         'zone = IIf(TimeZoneInfo.Local.IsDaylightSavingTime(thisTime), TimeZoneInfo.Local.DaylightName, TimeZoneInfo.Local.StandardName) + thisTime.ToString

       18         'zone += ("   UTC Time: {0}" + TimeZoneInfo.ConvertTimeToUtc(thisTime.ToString, TimeZoneInfo.Local).ToString)

       19 

       20 

       21         Return zone

    22                    End Function

     

    On my computer I get

    (GMT+10:00) Canberra, Melbourne, Sydney11/12/2009 3:33:26 PM <br />(GMT+10:00) Canberra, Melbourne, Sydney11/12/2009 3:33:26 PM<br />11/12/2009 3:33:26 PM(GMT+10:00) Canberra, Melbourne, Sydney

     

    Sydney being my home town but when I publish this to the site I get

     

    From the server I get

    Client-Side Date: (GMT-08:00) Pacific Time (US & Canada)11/11/2009 12:55:46 PM <br />(GMT-08:00) Pacific Time (US & Canada)11/11/2009 12:55:46 PM <br />

    Server Date:(GMT-08:00) Pacific Time (US & Canada)11/11/2009 5:57:42 PM <br />(GMT-08:00) Pacific Time (US & Canada)11/11/2009 5:57:42 PM <br />

     

    Client-side is US & Canada as the client I would hope to see Canberra, Melbourne, Sydney and I suppose that the US & Canada is correct for the server?

     

    Can anyone understand why the client-side information is correct

     

    Wednesday, November 11, 2009 11:50 PM

Answers

All replies

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, November 12, 2009 3:19 AM
  • User1823730432 posted

    Thank you for your reply

    From the information that you provided I think I have achieved this in my code

    The client time is correct as I receive a email from the website when I post from the login button which tells me the correct time when I view the page from the website on my computer and I get a time for the server  that I believe is the utc for the sever zone

     

    As I see it the utc is a latitude where Sydney Canberra and Melbourne are in the same latitude as china yet the code was able to display Australian Capital cities instead of china capital cities when I run the code on my server but the email displays us and canada from the website. the time and offset and daylight savings is correct.

    I what to see the correct cities just like canada and the US share the same latitude but I what to see US if I have view the website from the US and not canada

     

     

     

    Thursday, November 12, 2009 4:00 AM