Getting current Time in Specific Time Zone
I am trying to get current time using vbscript. Instead of the user/system time zone, I would like to get current CST time. How to get current time in some specific Time Zone using vbscript in TestComplete?
no, not with aqdatetime.
if you can find a reliable, free API that gives you current time at a specified timezone, then you could use the aqHttp object and do a get request.
then you'd most likely have to save the response body as a variable and then pull the proper key value pairs to output the time
for example, using the free api at http://api.timezonedb.com, I created a free account to access the current time in Chicago, the below stub is in Python, but the methods used will be available in vbscript as well at https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqhttp/creategetrequest.html
def get_CST(): address = "http://api.timezonedb.com/v2.1/get-time-zone?key=YOUR_API_KEY&format=json&by=zone&zone=America/Chicago" # Create an aqHttpRequest object aqHttpRequest = aqHttp.CreateGetRequest(address) # Send the request, get an aqHttpResponse object aqHttpResponse = aqHttpRequest.Send() if aqHttpResponse != None: # Read the response data Log.Message(aqHttpResponse.Text) # A response body df = aqHttpResponse.Text #in as a str date = df[-21:-2] #get daterange Log.Message(date) #log a message of current CST date return date #output date # Save the response body to a file and place it to the project folder #aqHttpResponse.SaveToFile(Project.Path + "body.txt")
and the following logs of running this routine: