calculating the GMT from current time
Hi Joe
Here is the code you should use:
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
Type TIME_ZONE_INFORMATION
Bias As Long
StandardName(0 To 32) As Integer
StandardDate As SYSTEMTIME
StandardBias As Integer
DaylightName(0 To 32) As Integer
DaylightDate As SYSTEMTIME
DaylightBias As Long
End Type
Declare Function GetTimeZoneInformation Lib "kernel32" _
(lpTimeZoneInformation As TIME_ZONE_INFORMATION) As Long
Declare Sub GetLocalTime Lib "kernel32" (lpSystemTime As SYSTEMTIME)
Sub GMT()
Dim udtLocalTime As SYSTEMTIME
Dim udtTimeZone As TIME_ZONE_INFORMATION
Dim dtGMT As Date
Dim dtLocal As Date
Dim lRetCode As Long
Dim nBias As Integer
Dim dtBias As Date
lRetCode = GetTimeZoneInformation(udtTimeZone)
nBias = udtTimeZone.Bias / 60
Call GetLocalTime(udtLocalTime)
With udtLocalTime
dtLocal = CDate(.wMonth & "/" & .wDay & "/" & .wYear & _
" " & .wHour & ":" & .wMinute & ":" & .wSecond)
End With
dtBias = CDate(Abs(nBias) & ":00:00")
If nBias >= 0 Then
dtGMT = dtLocal + dtBias
Else
dtGMT = dtLocal - dtBias
End If
MsgBox "LocalTime " & dtLocal & vbCrLf & "GMT " & dtGMT
End Sub
With respect
Alex
Quote:
> I am trying to write a program that will give me the GMT time,
> regardless of which timezone I am in. I can calculate the hours if
> someone could tell me where I can get timezone info and whether it is
> in daylight savingstime or not.
> Could anyone tell me how I could go about this?
> JoeB
Sent via Deja.com http://www.deja.com/
Before you buy.