Option Explicit 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(0 To 31) As Integer StandardDate As SYSTEMTIME StandardBias As Long DaylightName(0 To 31) As Integer DaylightDate As SYSTEMTIME DaylightBias As Long End Type Private Enum TIME_ZONE TIME_ZONE_ID_INVALID = 0 ' Cannot determine DST TIME_ZONE_STANDARD = 1 ' Standard Time, not Daylight TIME_ZONE_DAYLIGHT = 2 ' Daylight Time, not Standard End Enum Private Declare Function GetTimeZoneInformation Lib "kernel32" _ (lpTimeZoneInformation As TIME_ZONE_INFORMATION) As Long Private Declare Sub GetSystemTime Lib "kernel32" _ (lpSystemTime As SYSTEMTIME) ' Dim T As Date Dim TZI As TIME_ZONE_INFORMATION Dim TZInfo As TIME_ZONE Dim TimeLocal,TimeDTG,DTGNow As Date Dim DTGTime,DTGMonth,DTGYear As String ' Convert Computer Local Time To UTC Function ComputerTimeToDTG As Date ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' ComputerTimeToDTG ' This function returns the Military Date Time Group ' based on current Computer Time ' Note: Military Date Time Group does not observe Daylight Savings Time ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Dim TBias As Date Dim TZI As TIME_ZONE_INFORMATION Dim DST As TIME_ZONE Dim DTG As Date DST = GetTimeZoneInformation(TZI) ' DST=1 ' Test Standard Time Fudge Factor If DST = TIME_ZONE_DAYLIGHT Then TBias = TZI.DaylightBias Else TBias = 0 If TBias < 0 Then DTG = Now - TimeSerial(-TBias/60,0,0) Else DTG = Now + TimeSerial(TBias/60,0,0) End If ComputerTimeToDTG = DTG End Function Function GetMilitaryTimeCode(MCode As Long) As String ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' GetMilitaryTimeCode ' This returns the Military Time Code (Time Zone) Letter ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Dim MilCode As String Select Case -MCode ' Military Time Code (Time Zone) Value Reference Case -12 MilCode = "Y" ' UTC-12: Y- (e.g. Fiji) Case -11 MilCode = "X" ' UTC-11: X (American Samoa) Case -10 MilCode = "W" ' UTC-10: W (Honolulu, HI) Case -9 MilCode = "V" ' UTC-9: V (Juneau, AK) Case -8 MilCode = "U" ' UTC-8: U (PST, Los Angeles, CA) Case -7 MilCode = "T" ' UTC-7: T (MST, Denver, CO) Case -6 MilCode = "S" ' UTC-6: S (CST, Dallas, TX) Case -5 MilCode = "R" ' UTC-5: R (EST, New York, NY) Case -4 MilCode = "Q" ' UTC-4: Q (Halifax, Nova Scotia Case -3 MilCode = "P" ' UTC-3: P (Buenos Aires, Argentina) Case -2 MilCode = "O" ' UTC-2: O (Godthab, Greenland) Case -1 MilCode = "N" ' UTC-1: N (Azores) Case 0 MilCode = "Z" ' UTC+-0: Z (Zulu time) Case 1 MilCode = "A" ' UTC+1: A (France) Case 2 MilCode = "B" ' UTC+2: B (Athens, Greece) Case 3 MilCode = "C" ' UTC+3: C (Arab Standard Time, Iraq, Bahrain, Kuwait, Saudi Arabia, Yemen, Qatar) Case 4 MilCode = "D" ' UTC+4: D (Moscow, Russia, and Afghanistan = +4:30) Case 5 MilCode = "E" ' UTC+5: E (Pakistan, Kazakhstan, Tajikistan, Uzbekistan and Turkmenistan) Case 6 MilCode = "F" ' UTC+6: F (Bangladesh) Case 7 MilCode = "G" ' UTC+7: G (Thailand) Case 8 MilCode = "H" ' UTC+8: H (Beijing, China) Case 9 MilCode = "I" ' UTC+9: I (Tokyo, Australia) Case 10 MilCode = "K" ' UTC+10: K (Brisbane, Australia) Case 11 MilCode = "L" ' UTC+11: L (Sydney, Australia) Case 12 MilCode = "M" ' UTC+12: M (Wellington, New Zealand) Case 13 MilCode = "L" ' UTC+13: Locations are considered to be in UTC+11 Case 14 MilCode = "K" ' UTC+14: Locations are considered to be in UTC+10 Case Else SendKeys "**** ERROR: Unknown Resulting Military Time Code=" + CStr(MCode) + "{enter}" End Select GetMilitaryTimeCode = MilCode End Function Sub Main TZInfo = GetTimeZoneInformation(TZI) ' Required to get time zone info for Military Time Code Letter DTGNow = ComputerTimeToDTG ' Function to convert to Standard Time (No Daylight Savings in DTG) DTGMonth = Format(DTGNow,"mmm") DTGMonth = UCase$(DTGMonth) ' Convert three letter month to uppercase DTGYear = Format(DTGNow,"yy") DTGTime = Format(DTGNow,"ddhhmm") + GetMilitaryTimeCode(TZI.Bias/60) '<---TIME CODE LETTER SendKeys DTGTime + DTGMonth + DTGYear + " " End Sub