Solved

GetTimeZoneInformation

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Determine Range to Select 5 48
passing parameter in sql procedure 9 61
VB6 - Convert HH:MM into Decimal 8 54
Passing a Text Box name to a Sub 6 96
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…

808 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