CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Jun 2008
    Posts
    10

    Need Help displaying local time zone, please.

    Hi
    I would like to know how I can display the local time zone in a label but not just the GMT offset, I want the whole deal like Windows does.
    example: (GMT
    +/- offset)nameofcity

    Thanks to a snippet I found online I am able to populate a listbox with all of the Windows XP dafault time zones however I can't work out how to extract just the local TZ from the system.

    I'm using VB6, MSDN is way over my head as I'm not up to speed with the lingo.
    I learn better by example(s).

    Any help would be greatly appreciated. Thank you.
    BTW, I already have a Mod with the following:

    Code:
    Private Type SYSTEMTIME
       wYear As Integer
       wMonth As Integer
       wDayOfWeek As Integer
       wDay As Integer
       wHour As Integer
       wMinute As Integer
       wSecond As Integer
       wMilliseconds As Integer
    End Type
    
    Private Type REGTIMEZONEINFORMATION
       Bias As Long
       StandardBias As Long
       DaylightBias As Long
       StandardDate As SYSTEMTIME
       DaylightDate As SYSTEMTIME
    End Type
    
    Private Type TIME_ZONE_INFORMATION
        Bias As Long
        StandardName(31) As Integer
        StandardDate As SYSTEMTIME
        StandardBias As Long
        DaylightName(31) As Integer
        DaylightDate As SYSTEMTIME
        DaylightBias As Long
    End Type
    
    Private Const TIME_ZONE_ID_INVALID = &HFFFFFFFF
    Private Const TIME_ZONE_ID_UNKNOWN = 0
    Private Const TIME_ZONE_ID_STANDARD = 1
    Private Const TIME_ZONE_ID_DAYLIGHT = 2
    
    Private Declare Function GetTimeZoneInformation Lib "kernel32" _
    (lpTimeZoneInformation As TIME_ZONE_INFORMATION) As Long
    Last edited by AccadaccA; July 21st, 2010 at 09:26 PM. Reason: UNRESOLVED

  2. #2
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: Need Help displaying local time zone, please.

    Please us e[CODE] and [/CODE] tags when posting code.

  3. #3
    Join Date
    Jun 2008
    Posts
    10

    Re: [RESOLVED] Need Help displaying local time zone, please.

    Sorry for not using code tags.

    I have found the answer, well at least something I can work with to get the desired info.

    http://vbnet.mvps.org/code/locale/ti...biaslookup.htm

  4. #4
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: [RESOLVED] Need Help displaying local time zone, please.

    Thanx for sharing your answer. It helps members in future with the same problem, to fix theirs

    Hannes

  5. #5
    Join Date
    Jun 2008
    Posts
    10

    Re: [RESOLVED] Need Help displaying local time zone, please.

    I jumped the gun a little thinking that my problem was resolved. Although the link points to a good script it still doesn't return the results I'm after.

    I am in Brisbane, Australia which is GMT + 10:00, however it appears that all scripts relating to Regional Time Zones return the offset value of "-600" on my system, where it should read "+600" minutes which throws it out by 1200 minutes / 20 hours. Not exactly accurate, hey?

    Now going back to my original post, we know that there is a way of getting what I'm after as Windows does it during the setup process and a snippet of a script by Paul Turcksin populates a listbox with all of the Regional Time Zones in the same format.
    I had included a snippet of his code below but then read that it was forbidden to do so without his written consent. Unfortunately he failed to include his email address.

    So the question is does anybody here know of an API or registry call that will return the following:
    example: (GMT+/- offset)nameofcity

    as in: (GMT +10:00) Brisbane
    or: (GMT -06:00) Central Time (US & Canada)
    etc.

    Thank you for you tolerance.

  6. #6
    Join Date
    Apr 2009
    Posts
    394

    Re: [RESOLVED] Need Help displaying local time zone, please.


  7. #7
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: [RESOLVED] Need Help displaying local time zone, please.

    One nice thing about VB.Net is UTCDateTime
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  8. #8
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: Need Help displaying local time zone, please.

    I edited the thread title back to normal

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured