Converting Coordinated Universal Time (UTC) to Local Time and Vice Versa in DIAdem Using VBS

Updated May 15, 2025

Environment

Software

  • DIAdem

Programming Language

  • Visual Basic

When creating or reading a data file, it is common for users to convert the date-time information accordingly to prevent misunderstanding. In this article, we will show how to convert a predefined UTC time to local time and also how to convert local time to UTC time.

Converting UTC to Local Time

  1. In DIAdem SCRIPT pane, create a new SWbemDateTime object from WMI scripting type library. 
    Set dateTime = CreateObject("WbemScripting.SWbemDateTime")
  2. Predefined a dummy UTC to convert to local time.
    dummyUTC = "05-05-2025 13:19:00"
  3. Convert the dummy time into the Variant type with the Date subtype.
    convertedUTC = CDate(dummyUTC)
  4. Use SetVarDate method of the SWbemDateTime object to convert the dummy time to CIM datetime format. The second parameter must be False to have the method interpret the dummy time provided as UTC
    Call dateTime.SetVarDate(convertedUTC ,False)
  5. Use GetVarDate method of the SWbemDateTime object with True parameter to retrieve the dummy time as local time.
    LocalTime = dateTime.GetVarDate(True) 

Converting Local Time to UTC

  1. In DIAdem SCRIPT pane, create a new SWbemDateTime object from WMI scripting type library. 
    Set dateTime = CreateObject("WbemScripting.SWbemDateTime")
  2. Obtain current local time using Now function of VBS.
    currentTime = Now()
  3. Convert the dummy time into the Variant type with the Date subtype.
    convertedUTC = CDate(currentTime)
  4. Use SetVarDate method of the SWbemDateTime object to convert the dummy time to CIM datetime format. The second parameter must be True to have the method interpret the provided time as local time.
    Call dateTime.SetVarDate(convertedUTC ,True)
  5. Use GetVarDate method of the SWbemDateTime object with False parameter to retrieve the time as UTC.
    UTCTime = dateTime.GetVarDate(False) 

Converting UTC to Local Time

Converting Local Time to UTC