DIAdem Help

Method: ParseDateTime for JsonParser

  • Updated2024-09-12
  • 1 minute(s) read

Method: ParseDateTime for JsonParser

Converts a date according to ISO 8601 into a variable with the subtype Date.

Set oDispatch = Object.ParseDateTime(String, LocalTime)
ObjectJsonParser
Object with this method
StringString
Receives the date according to ISO 8601.
LocalTimeBoolean
Specifies whether the method returns the time as local time (TRUE) or as UTC (Coordinated Universal Time) (FALSE).
oDispatchReturned object

The following example creates a dictionary object from a JSON object, converts the "timestamp" item into a VBS date/time value, and displays the time values in the log area.

VBScriptPython

 

Dim oJsonParser, sJsonDateTimeTag, oVbsObject, sVbsDictItem, VbsDate
Set oJsonParser = CreateJsonParser()
sJsonDateTimeTag = "{""timestamp"":""2018-11-27T12:33:27Z""}"
Call oJsonParser.Deserialize(sJsonDateTimeTag, oVbsObject)
sVbsDictItem = oVbsObject("timestamp")
VbsDate = oJsonParser.ParseDateTime(sVbsDictItem,True)
Call LogFileWrite("Local Time: " & CStr(VbsDate))
VbsDate = oJsonParser.ParseDateTime(sVbsDictItem,False)
Call LogFileWrite("UTC Time: " & CStr(VbsDate))

Log in to get a better experience