Skip to main content
15-Moonstone
January 23, 2023
Question

Convert the datetime from any timezone to UTC timezone

  • January 23, 2023
  • 1 reply
  • 2036 views

Hi all,

 

I am looking for a conversion from my system timezone say (IST) to UTC (00:00) timezone. I have used toUTCString function and then reverted back to YYYY-MM-DD hh:mm:ss format (DateTime as output) but it fails. So, what is an alternative to achieve this?

 

Thank you

1 reply

17-Peridot
January 23, 2023

Hello,

 

Where would you like this conversion to happen?

If you are thinking about backend then all dates are handled using UTC (unless you have changed the timezone in the platform configurations).

If you are thinking about frontend then thingworx also automatically converts from UTC to the browsers local time.

 

I'm not sure it is possible to use the datetime variable type for this, instead you might have more luck using a string (as it will not get converted).

 

Regards,

Jens

15-Moonstone
January 23, 2023

Hi Jens,

 

Thank you for the quick response, yes I am trying at the backend, I have a service where I am giving the DateTime, by default the time is set to 00:00, so when I set my system to UTC, on hover of the graph shows correct data i.e. 00:00 but when I change say IST then it shows 5:30 on hover, so I want to know if my input itself can be converted into UTC then my output will always show 00:00.

 

 

Thank you! 

17-Peridot
January 23, 2023

Hello,

 

Thank you for your clarifications.

I found this support ticket: Link

Perhaps it can help you. There seem to be some information to prevent datetime conversions.

 

Regards,

Jens