Solved

GetTimeZoneInformation

Posted on 2002-07-15
2
1,538 Views
Last Modified: 2012-08-14
Hi,
I need to determine what GMT it is. I'm validating against a GMT sent from Sybase which APPEARS to give the correct GMT. Using VB I get errors because tthe VB version is an hour out. Now, using the code below, I tried looking at two dates, one in Jan, another in July. London should be one hour different. I tried Sydney too and that should make 1 hour, the opprsite way BUT the Bias I get from GetTimeZoneInformation seems to be identical. What am I doing wrong? Is there another solution? (I'm on Windows 2000, VB6)


Dim MyTZ As OS_TIME_ZONE_INFORMATION

  Call GetTimeZoneInformation(MyTZ)
  GetDateTimeGMT = Now + (MyTZ.Bias / 60) / 24
  Debug.Print Format(Date, "MMM-DD"); "  MyTZ.Bias="; MyTZ.Bias / 60
 
  sName = ""
  For i = 0 To 32
    If (MyTZ.DaylightName(i) = 0) Then Exit For
    sName = sName + Chr(MyTZ.DaylightName(i))
  Next
  Debug.Print "MyTZ.DaylightName="; sName & "MyTZ.DaylightBias="; MyTZ.DaylightBias / 60
  Debug.Print " "; MyTZ.DaylightDate.wDay & "/"; MyTZ.DaylightDate.wMonth & "/"; MyTZ.DaylightDate.wYear
  Debug.Print " "; MyTZ.DaylightDate.wHour & ":" & MyTZ.DaylightDate.wMinute;
  Debug.Print " ["; MyTZ.DaylightDate.wSecond & "s]"

  sName = ""
  For i = 0 To 32
    If (MyTZ.StandardName(i) = 0) Then Exit For
    sName = sName + Chr(MyTZ.StandardName(i))
  Next
  Debug.Print "MyTZ.StandardName="; sName; " StandardBias="; MyTZ.StandardBias
  Debug.Print " "; MyTZ.StandardDate.wDay & "/"; MyTZ.StandardDate.wMonth & "/"; MyTZ.StandardDate.wYear
  Debug.Print " "; MyTZ.StandardDate.wHour & ":" & MyTZ.StandardDate.wMinute & " ["; MyTZ.StandardDate.wSecond & "s]"


-------------GIVES------------
London Jan-15  MyTZ.Bias= 0
MyTZ.DaylightName=T Daylight Time
MyTZ.DaylightBias= 0
  0 / 1 / 5
  0 :-60 [-1s]
MyTZ.StandardName=GMT Standard Time
 StandardBias= 5046343
  2 / 0 / 10
  0 :0 [0s]


London Jul-15  MyTZ.Bias= 0
MyTZ.DaylightName=T Daylight Time
MyTZ.DaylightBias= 0
  0 / 1 / 5
  0 :-60 [-1s]
MyTZ.StandardName=GMT Standard Time
 StandardBias= 5046343
  2 / 0 / 10
  0 :0 [0s]

------------------------------------------------
Sydney-Jan15 MyTZ.Bias=-10
MyTZ.DaylightName=S Eastern Daylight Time
MyTZ.DaylightBias= 0
  0 / 2 / 5
  0 :-60
 -1s
MyTZ.StandardName=AUS Eastern Standard Time
 StandardBias= 5570625
  2 / 0 / 3
  0 :0
 0s

Sydney Jul-15  MyTZ.Bias=-10
MyTZ.DaylightName=S Eastern Daylight Time
MyTZ.DaylightBias= 0
  0 / 2 / 5
  0 :-60 [-1s]
MyTZ.StandardName=AUS Eastern Standard Time
 StandardBias= 5570625
  2 / 0 / 3
  0 :0 [0s]



0
Comment
Question by:BJStearn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 20

Accepted Solution

by:
hes earned 50 total points
ID: 7155070
0
 
LVL 28

Expert Comment

by:Ark
ID: 7155879
Hi
Take a look on my sample at http://www.freevbcode.com/ShowCode.Asp?ID=1749

Cheers
0

Featured Post

Enroll in July's Course of the Month

July's Course of the Month is now available! Enroll to learn HTML5 and prepare for certification. It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses
Course of the Month9 days, 19 hours left to enroll

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question