question

GregMcNamara-1608 avatar image
0 Votes"
GregMcNamara-1608 asked asergaz answered

Iot Edge container incorrectly converting local datetime to UTC

Hi,
I have an IoT Edge module which connects to an on-premise WCF API. One of the API calls returns a local datetime value to the module, with the local timezone specified. I noticed that when that datetime value is serialized into a D2C telemetry message, it has been converted to UTC and the timezone information has been removed. In most cases that would be fine, however I need to use the local datetime as part of a key for data integration with an on-premise database. It looks like the module container is set to UTC timezone, so it seems to be automatically converting the value either to the container's timezone or to UTC by default. Is there a way I can ensure the local datetime value returned by the API is not automatically converted to the container's timezone?
Thanks,
Greg

azure-iot-edge
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello @GregMcNamara-1608,

1) Could you please confirm the IoT Edge module you are using? Did you build one yourself?
2) Are you using IoT Edge routing over AMQP or MQTT? Or are you using the MQTT broker?
3) If using routing what is the Azure IoT SDK language?

Thanks!

0 Votes 0 ·

Hi @asergaz,

In answer to your questions:

1) It's a custom module developed in C# with Visual Studio 2019.
2) IoT Edge routing with MQTT. Not using the broker at this stage, but might in future for connecting downstream devices.
3) C# (.net core 3.1)

Thanks,
Greg

1 Vote 1 ·

1 Answer

asergaz avatar image
0 Votes"
asergaz answered

Thanks for the clarification in the comments @GregMcNamara-1608,

My suggestion is that you use Application Properties of D2C IoT Hub messages

A common use of application properties is to send a timestamp from the device using the iothub-creation-time-utc property to record when the message was sent by the device. The format of this timestamp must be UTC with no timezone information.

In your case, you can define the creation time, having into account the timezone retrieved by your API call.


Remember:
- Please accept an answer if correct. Original posters help the community find answers faster by identifying the correct answer. Here is how.
- Want a reminder to come back and check responses? Here is how to subscribe to a notification.






5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.