Private Sub Timer1_Timer()
Dim datUTC As Date
datUTC = Time_LocalToUTC(Now)
Me.lblCurrentTimeActual.Caption = Now
Me.lblUTCTimeActual.Caption = CStr(datUTC)
Me.lblPhilippinesTimeActual.Caption =
CStr(DateAdd("h", 8, datUTC))
End Sub
Public Function Time_LocalToUTC(ByVal
the_date As Date) As Date
On Error GoTo ErrorTrap
' Create a new instance of the WScript
Shell
Dim oWshshell As Variant
Dim UTCOffset As Long
Set oWshshell =
CreateObject("WScript.Shell")
'从复制通用时间时钟偏移登记处这确实说明了日光节省
UTCOffset = oWshshell.RegRead("HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlTimeZoneInformationActiveTimeBias")
'使用当前系统时间,并从注册表中添加UTC偏移量。生产1440'取60*24,因为一天的单位有1等于一天Time_LocalToUTC=日期+(UTC偏移/1440(GoTo EndCleanup错误陷阱:MsgBox"错误:"&错误描述,vbOKCancel,"获取UTC时间时出错">
EndCleanup:
Set oWshshell = Nothing
End Function[enter image description here]
[1]
Me.Label1.Caption = Format$(CStr(DateAdd("h", 8,
datUTC)), "hh:mm:ss AM/PM")
Me.Label2.Caption = Format$(CStr(DateAdd("h", 8,
datUTC)), " mmmm dd, yyyy")
这解决了它。哈哈