Declare Function GetTimeZoneInformation& Lib _
"kernel32" (lpTimeZoneInformation As _
TIME_ZONE_INFORMATION)
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 As String * 64
StandardDate As SYSTEMTIME
StandardBias As Long
DaylightName As String * 64
DaylightDate As SYSTEMTIME
DaylightBias As Long
End Type
Function TimeInZone(ByVal TimeZone As String) As Variant
Dim TZ As TIME_ZONE_INFORMATION
Dim TimeZoneBias As Integer
TimeZone = UCase(Left$(TimeZone, 1))
GetTimeZoneInformation TZ
TimeZoneBias = TZ.Bias \ 60
Select Case TimeZone
Case "E"
TimeInZone = DateAdd("h", TimeZoneBias - 5, Now)
Case "C"
TimeInZone = DateAdd("h", TimeZoneBias - 6, Now)
Case "M"
TimeInZone = DateAdd("h", TimeZoneBias - 7, Now)
Case "P"
TimeInZone = DateAdd("h", TimeZoneBias - 8, Now)
Case "A"
TimeInZone = DateAdd("h", TimeZoneBias - 9, Now)
Case "H"
TimeInZone = DateAdd("h", TimeZoneBias - 10, Now)
Case Else
TimeInZone = -1
Exit Function
End Select
TimeInZone = Format$(TimeInZone, "Long Time")
End Function
This function (TimeInZone) is called with a single parameter -- the first
letter of the US time zone. You can, internal self-documenting purposes,
provide more of the time zone's name if you wish, but anything you type
after the first letter is ignored (and will *not* be checked for accuracy).
By the way, this function will respond to all US time zones; those being:
Eastern, Central, Mountain, Pacific, Alaska, Hawaii.
Rick
Louis M. Garvin wrote in message ...