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

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

How to fix DateTime property timezone in mashup?

miikkae
12-Amethyst

How to fix DateTime property timezone in mashup?

I've a console application sending data to ThingWorx service using .NET SDK, that adds those calls as an infotable property row.

From the .NET app I debug the logs from the parameters send to the service and the dateTime seems ok but on ThingWorx mashup where I list the rows from that property in a grid, there's three hours offset.

I've checked that the timezone is correct on the server running ThingWorx and tried using DateTime.SpecifyKind function in .NET to specify the time as DateTimeKind.Utc / DateTimeKind.Local before invoking the service with those parameters but nothing seems to be working.

Could someone tell me how to get rid of this +3h offset? I'm trying to track live events from a sensor on mashup but it's kinda annoying to always get the time three hours in the future.

5 REPLIES 5
paic
12-Amethyst
(To:miikkae)

The Thingworx server uses UTC, and then browser side that information is translated into the Time zone of the browser.

Since you already made sure that UTC is correct on the server, then most likely the SDK is submitting time that is not UTC or the device is not set correctly?

miikkae
12-Amethyst
(To:paic)

The device talking to TWX SDK is outputting correct local time and in the program I escpecially set


DateTime.SpecifyKind(date, DateTimeKind.Utc);



The timezones are checked and correct in

  1. Current browser
  2. Device communicating to ThingWorx SDK
  3. ThingWorx server

They are even all in the same timezone. Got no idea where the -3 hours come from.

paic
12-Amethyst
(To:miikkae)

Is the property bound? or do you do any handling with the date/time before storing it?

I would log the value at each step to the script log just to see if at anytime it changes at all.

Beyond that I am not sure what might be going on with your setup.

miikkae
12-Amethyst
(To:paic)

The property is not bound and actually the property is infotable "Just Infotable" that has the fields with datetime values.

Logging seems like be a great idea but I'm just afraid the time has changed when the input parameter arrives.

Thanks for the tip anyway, I'll try it tomorrow

miikkae
12-Amethyst
(To:paic)

Finally had time and remembered to test this.

Logged the time parameter and while the log timestamp is 2015-10-19 16:05:11, it printed: Mon Oct 19 2015 19:05:13 GMT+0300 (EEST).

I'm guessing the two seconds are from clocks not in sync while the printed value should be the time launched from software and log timestamp the time the service was run (so it should be earlier or the same at latest).

I finally fixed this by setting: time.setHours(time.getUTCHours()); before adding the row.

Doesn't seem like a great solution but the TWX service assumes the datetime is always current timezone (GMT+3) no matter what I timezone I set in .NET program.

Announcements


Top Tags