GetTimeZoneInformation api can be used to fetch the timezoen of a user's computer.


Example

{code}

Private Const TIME_ZONE_ID_STANDARD = 1
Private Const TIME_ZONE_ID_UNKNOWN = 0
Private Const TIME_ZONE_ID_INVALID = &HFFFFFFFF
Private Const TIME_ZONE_ID_DAYLIGHT = 2

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(62) As Byte
StandardDate As SYSTEMTIME
StandardBias As Long
DaylightName(62) As Byte
DaylightDate As SYSTEMTIME
DaylightBias As Long
End Type

Declare Function GetTimeZoneInformation Lib "kernel32" _
(lpZoneInfo As TIME_ZONE_INFORMATION) As Long

Public Function GetTZ() As String
    Dim pZoneInfo As TIME_ZONE_INFORMATION
    Dim nRetVal As Long
    Dim sDayLight As String
   
    nRetVal = GetTimeZoneInformation(pZoneInfo)
    n = CStr(pZoneInfo.StandardName)

    If InStr(1, n, "India Standard Time", vbTextCompare) Then
            f = "IST"
    ElseIf InStr(1, n, "Eastern Standard Time", vbTextCompare) Then
        If nRetVal = TIME_ZONE_ID_DAYLIGHT Then
            f = "EDT"
        Else
            f = "EST"
        End If
    End If
    GetTZ = f
End Function

{/code}

In the example, the GetTZ() returns IST for Indian standard time and EDT for Eastern time with daylight savings and EST for Eastern standard time.