Convert DateTime To and From UTC

Back to VBScript

Function ConvertLocalToUTC( varTime ) Dim myObj, MyDate MyDate = CDate( varTime ) Set myObj = CreateObject( "WbemScripting.SWbemDateTime" ) myObj.SetVarDate MyDate, True 'Input = Local = True ConvertLocalToUTC = myObj.GetVarDate( False) ' Output = Not Local = True End Function 'ConvertLocalToUTC Function ConvertUTCToLocal( varTime ) Dim myObj, MyDate MyDate = CDate( varTime ) Set myObj = CreateObject( "WbemScripting.SWbemDateTime" ) myObj.SetVarDate MyDate, False 'Input = Not Local = False ConvertUTCToLocal = myObj.GetVarDate( True) ' Output = Local = True End Function 'ConvertUTCToLocal