Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

GetTimeZoneInformation

Posted on 2002-07-15
2
Medium Priority
?
1,554 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 200 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

704 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