Solved

GetTimeZoneInformation

Posted on 2002-07-15
2
1,497 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
2 Comments
 
LVL 20

Accepted Solution

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

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

762 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now