Retrieve Local Time Zone Information

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I retrieve the local time zone information from a MS Access form?

For example, my computer "Date and Time Properties" is set to "(GMT+10:00)
Canberra, Melbourne, Sydney". How do I retrieve such information?
 
This should get you started. On a new form put a command button named
cmdGetTimeZoneInfo and paste the code below in the code module for the form.
On my system located on the east coast of the US I see:

Time Zone Bias in minutes = 300 in hours = 5
Standard Name = E a s t e r n S t a n d a r d T i m e
Standard Date begins = 10 / 5
Standard Bias = 0
Daylight Name = E a s t e r n D a y l i g h t T i m e
Daylight Date begins = 4 / 1
Daylight Bias = -60

Basically it says that I am 300 minutes behind GMT (My time + 300 = GMT). I
believe you should see a -600 minutes in your time zone as you are 10 hours
ahead of GMT.

' -- Code Starts --
Option Compare Database
Option Explicit

Private Declare Function GetTimeZoneInformation& Lib "kernel32" _
(lpTimeZoneInformation As TIME_ZONE_INFORMATION)

Private Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type

Private Type TIME_ZONE_INFORMATION
Bias As Long
StandardName As String * 64
StandardDate As SYSTEMTIME
StandardBias As Long
DaylightName As String * 64
DaylightDate As SYSTEMTIME
DaylightBias As Long
End Type

Private Sub cmdGetTimeZoneInfo_Click()

Dim TZI As TIME_ZONE_INFORMATION

Call GetTimeZoneInformation(TZI)
Debug.Print "Time Zone Bias in minutes = "; TZI.Bias; " in hours = " &
TZI.Bias / 60
Debug.Print "Standard Name = "; TZI.StandardName
Debug.Print "Standard Date begins = "; TZI.StandardDate.wMonth; "/";
TZI.StandardDate.wDay
Debug.Print "Standard Bias = "; TZI.StandardBias
Debug.Print "Daylight Name = "; TZI.DaylightName
Debug.Print "Daylight Date begins = "; TZI.DaylightDate.wMonth; "/";
TZI.DaylightDate.wDay
Debug.Print "Daylight Bias = "; TZI.DaylightBias
End Sub
' -- Code Ends --

Ron W
 
Back
Top