Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X
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!!
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.