Вот моя собственная попытка.Лучшие решения будут любезно приняты!
Function ToDateTimeStringMinimalSeparators(dateTime)
' --------------------------------------------------------------------------
' F O R M A T T H E U T C O F F S E T
' --------------------------------------------------------------------------
Dim oShell, activeTimeBias
Set oShell = CreateObject("WScript.Shell")
activeTimeBias = oShell.RegRead("HKEY_LOCAL_MACHINE\System\" & _
"CurrentControlSet\Control\TimeZoneInformation\ActiveTimeBias")
Dim sign
sign = "-"
If activeTimeBias < 0 Then
sign = "+"
' Make it positive while we're doing calculations
activeTimeBias = activeTimeBias * -1
End If
Dim atbHours, atbMins
atbHours = Right("00" & Int(activeTimeBias / 60), 2)
atbMins = Right("00" & (activeTimeBias Mod 60), 2)
If atbMins = "00" Then
atbMins = ""
End If
Dim utcOffset
utcOffset = sign & atbHours & atbMins
' --------------------------------------------------------------------------
' F O R M A T T H E M A I N D A T E
' --------------------------------------------------------------------------
Dim dateBody
dateBody = Right("0000" & Year(dateTime), 4) & _
Right("00" & Month(dateTime), 2) & _
Right("00" & Day(dateTime), 2) & _
"T" & _
Right("00" & Hour(dateTime), 2) & _
Right("00" & Minute(dateTime), 2) & _
Right("00" & Second(dateTime), 2)
ToDateTimeStringMinimalSeparators = dateBody & utcOffset
End Function