Attribute VB_Name = "VBAUTCNow"
Option Explicit

Private Enum TIME_ZONE
  TIME_ZONE_DAYLIGHT = 2
End Enum

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 Declare Function GetTimeZoneInformation Lib "kernel32" _
    (lpTZI As TIME_ZONE_INFORMATION) As Long

Function UTC_Now() As Date
    Dim t As Date
    t = Now
    Dim tzi As TIME_ZONE_INFORMATION
    Dim dst As TIME_ZONE
    Dim gmt As Date
    dst = GetTimeZoneInformation(tzi)
    gmt = t + TimeSerial(0, tzi.bias, 0) - IIf(dst = TIME_ZONE_DAYLIGHT, TimeSerial(1, 0, 0), 0)
    UTC_Now = gmt
End Function
