cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

Timezone Problem

chenzhuang111
7-Bedrock

Timezone Problem

   hi  ,i get  a different date after use function dateFormat(new Date(),"yyyy-MM-dd")  and new Date(); i guess it was a Timezone Problem,

 

would you please tell me how to change the timezone to GMT+08 in thingworx?

1660905320116.png

1660905399623.png

 

ACCEPTED SOLUTION

Accepted Solutions

try to edit and check

 

C:\Program Files (x86)\ThingWorxFoundation\tomcat\apache-tomcat-9.0.62\bin\tomcat_windows_service.bat

 

also refer... https://www.ptc.com/en/support/article/CS331340

 

Note: I haven't tested. Please be cautious.

View solution in original post

6 REPLIES 6

and my thingworx version is 9.3.0

try this..

let dateValue = new Date();
let calculatedDateValue = dateAddMinutes(dateValue, 480);
result = dateFormat(calculatedDateValue,"yyyy-MM-dd HH:mm:ss") ;

 https://www.ptc.com/en/support/article/CS240366

 

hello,thanks for your reply,  I noticed the option 2,but what the method i installed thingworx is using ThingWorxFoundationPostgres-9.3.0-x64.exe,

in this way ,how can i add -Duser.timezone=GMT+08  to  Java Options?

try to edit and check

 

C:\Program Files (x86)\ThingWorxFoundation\tomcat\apache-tomcat-9.0.62\bin\tomcat_windows_service.bat

 

also refer... https://www.ptc.com/en/support/article/CS331340

 

Note: I haven't tested. Please be cautious.

Hello,

 

You could try this since you are running thingworx 9.3.0:

 

 

let params = {
        timezoneName: 'Asia/Hong_Kong' /* STRING */ 
};
let offset = Resources["TimezoneServices"].GetOffsetFromTimezone(params);
let offsethrs = offset / 100;

let DateTimeIn = new Date();
let datehrs = dateAddHours(DateTimeIn, offsethrs);

let isoFormat = dateFormatISO(datehrs);

 

This way you would get the timezone of Hong Kong, but if you lookup the tzdata list on wikipedia you can also find others.

Hope this helps.

 

Best regards.

@chenzhuang111 ,

 

Can you tell us the use case for the new Date()?  On the server, TWx should be using UTC time.  In the mashups, it gets converted to the local time on that clients machine.  The dates that appear in the Composer services can be a bit confusing because of this.  If you're looking to do date calculations in back-end services, you should be able to assume that ThingWorx will be using the UTC date.  If you are creating dates to show on mashups, I would maybe suggest using the Expression functions where possible to create those as I find it less confusing (and you eliminate a back-end call to the server).

 

-Nick

Announcements


Top Tags