Solved

GetTimeZoneInformation

Posted on 2002-07-15
2
1,503 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

930 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

10 Experts available now in Live!

Get 1:1 Help Now