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

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Unable to set time at 00:00:00 hours for other timezone

DM_10148696
3-Visitor

Unable to set time at 00:00:00 hours for other timezone

Hi all,

I am new to the thingworx platform, and I am trying to play around Date Time. Currently, I am using the 9.3 version. I have tried to set the default hours in service for that I used "result = new Date().setHours(0,0,0,0)" which is giving result as "2022-02-25 00:00:00.000" output is DataTime. My Thingworx server and browser both are in UTC. When I change the browser time to IST or EST the output varies. The output for IST is "2022-02-25 05:30:00.000"

and for EST is "2022-02-24 19:00:00.000". How can I set midnight time irrespective of time zone?

 

Thank you!!

1 REPLY 1
DanZ
15-Moonstone
(To:DM_10148696)

Hi,

Thingworx converts all datetime datatypes automatically to your browser timezone when you return them in the runtime or in the composer (for example via service call). In the backend the datetime is still in UTC (or the timezone that you've set on your TWX server). So if you want to see the "true" (backend) time, your service should return the time as string.

Another possible way is to use an expression in a mashup that returns the browsers timezone offset ( dateVar.getTimezoneOffset() ). Then you are able to manipulate the datetime with this result in runtime.

Top Tags