Hello, I'm newbie in AutoIT. I'm trying to get the date and time from a web service which returns the current local time for a given timezone as either plain-text or JSON.
Here is the website: http://worldtimeapi.org/api/timezone/Asia/Bangkok
JSON:
{"abbreviation":"+07","client_ip":"183.81.120.244","datetime":"2021-07-23T14:00:22.225651+07:00","day_of_week":5,"day_of_year":204,"dst":false,"dst_from":null,"dst_offset":0,"dst_until":null,"raw_offset":25200,"timezone":"Asia/Bangkok","unixtime":1627023622,"utc_datetime":"2021-07-23T07:00:22.225651+00:00","utc_offset":"+07:00","week_number":29}
Here is what I found
Local $String = BinaryToString(INetRead ("http://worldtimeapi.org/api/timezone/Asia/Bangkok",1))
$Obj = Json_Decode($String)
$datetime = functionOfMyDreams($Obj, "" ,"datetime")
ConsoleWrite($datetime)
Func functionOfMyDreams($decodedObject, $targetObject, $targetKeyInObject)
$value = Json_Get($decodedObject, '["' & $targetObject & '"]["' & $targetKeyInObject & '"]')
return $value
EndFunc ;==>functionOfMyDreams
The UDF: https://www.autoitscript.com/forum/topic/104150-json-udf-library-fully-rfc4627-compliant/