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

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

How to handle daylight savings and timezone offset values

Willie
16-Pearl

How to handle daylight savings and timezone offset values

I am trying to display timestamp in local time where the asset is located (local time = asset time).  I try to do this by

1.  storing the local time in UTC time (server time) on the server (no offset)

2.  get the timezone offset using the user's IP (user is person viewing the mashup)

3.  add the timezone offset to the startDate and endDate of the query

4.  subtract the timestamp value by the timezone offset value to display the data in the grid in asset time

 

This works great except the part when there was a daylight savings adjustment in the past.

Please see image below:

 

All of these records were restored with 00:00:00 for time, but you can see that the time shifted by 1 hour when daylight savings started on March 8th, 2020 in the US.  When I use the timezone offset in step #2, I am using the current offset, which is -7.  When I apply this to the query, it is applying it to all records even though some records need offset of -8 due to daylight savings adjustment.  I can't get and apply historical timezone offset values.

 

How can I fix this?????

 

Thingworx - 2020-10-02 - Timezone offset issue.PNG

1 ACCEPTED SOLUTION

Accepted Solutions
Willie
16-Pearl
(To:Willie)

I was able to resolve the issue based on the article below.  Timezone offset should be dealt with when adding the data to streams, etc., not afterwards like I had in my original post.

 

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

 

 

View solution in original post

7 REPLIES 7
Willie
16-Pearl
(To:Willie)

In addition, I think the server goes by US DST schedule.  DST starts/ends on different dates/times around the world.

https://www.timeanddate.com/time/dst/2020.html

 

By the way, our server is PTC cloud hosted.

 

Maybe the server should not adjust to daylight savings. 

slangley
23-Emerald II
(To:Willie)

Hi @Willie.

 

We recommend running ThingWorx in UTC to avoid time change issues.  Here's a link from the 9.0 Help Center regarding timezones.

 

Since your site is hosted, I recommend opening a case for the Cloud team.  I will be happy to open the case on your behalf, if you would like.

 

Regards.

 

--Sharon

@slangley 

 

I think our server is actually in UTC time.  The thingworx applicaiton adjusts the time displayed based on the user's timezone (person viewing mashup).  Depending on the date stored in the application, it will adjust the offset appropriate for that time. So from March 8th, 2020 to Novermber 5th, 2020, it uses offset of -7.  It uses offset of -8 before March 8th, 2020 to November 3, 2019.  

Hi Willie,

Do you know if this instance was upgraded in-place from 7.0 ?

If it s hosted by PTC Cloud  ? can you send me in PM its URL (except if you have already opened a support case).

Thanks.

@smainente 

 

It was not upgraded from 7.0.  I think we started on 8.2. We are on 8.5.3 now.

I will send you a PM.

 

Willie
16-Pearl
(To:Willie)

I was able to resolve the issue based on the article below.  Timezone offset should be dealt with when adding the data to streams, etc., not afterwards like I had in my original post.

 

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

 

 

slangley
23-Emerald II
(To:Willie)

Hi @Willie.

 

I'm glad to hear that you resolved the issue, and thank you for sharing the solution.  Please mark your previous post as the Accepted Solution for the benefit of others with the same issue.

 

Thank you for your participation in our community!

 

Regards.

 

--Sharon

Top Tags