Hi,
After lot of manipulation in the TimeStamp with Thingworx and JS Functions was not able to get proper time zone, so used the Third Party API for this. Use the below Code:
var params = {
proxyScheme: 'http' /* STRING */,
headers: {"Accept-Encoding":"gzip, deflate, br","Accept":"*/*","Content-Type": "application/json"},
ignoreSSLErrors: true,
url: "http://worldtimeapi.org/api/timezone/America/Chicago" /* STRING */,
};
// result: JSON
var CDTdate = Resources["ContentLoaderFunctions"].GetJSON(params);
//date = CDTdate.datetime;
date = ((CDTdate.datetime).split("T")[0]);
time = ((CDTdate.datetime).split("T")[1]);
timestamp = ((time).split(".")[0]);
hours = timestamp.split(":")[0];
if(hours > 12 ){
result = date + " " + timestamp + " PM CDT";
}
else{
result = date + " " + timestamp + " AM CDT";
}
Thanks,
Shashi