Time Zone Adjustment in OPC History Request|OPC UA Standard|Forum|OPC Foundation

Avatar
Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
Lost password?
sp_Feed sp_PrintTopic sp_TopicIcon
Time Zone Adjustment in OPC History Request
Avatar
Santosh
Member
Members
Forum Posts: 6
Member Since:
07/10/2023
sp_UserOfflineSmall Offline
1
09/15/2025 - 23:36
sp_Permalink sp_Print

We’ve identified a time discrepancy when sending History requests via the OPC library. Specifically, although we are setting the StartTime as 10:10 AM, the OPC library is automatically adjusting this to CDT (-5 hours), which aligns with the time zone of the VM where the request is being executed. This means the actual request being sent is interpreted as 5:10 AM CDT, not the originally intended 10:10 AM UTC. We’re currently looking into ways to handle this adjustment, either by explicitly converting the time to UTC before sending or by configuring the library to respect the intended time zone. Please let me know if anyone has encountered similar behavior or have suggestions on how best to handle this.

Avatar
Paul Hunkar
Cleveland, Ohio, USA
Moderator
Members

Moderators-Specifications

Moderators-Companion

Moderators-Implementation

Moderators-Certification

Moderators-COM
Forum Posts: 124
Member Since:
02/24/2014
sp_UserOfflineSmall Offline
2
09/22/2025 - 04:52
sp_Permalink sp_Print

In OPC UA time is always in UTC, so all parameters to methods or services are expecting the time to be provided in UTC.  All Servers are  expecting parameters and services to provided UTC time.  Data value (SourceTimestamp and ServerTimeStamps) are also in UTC Time.   In a historian that data is stored as UTC Time.

With this understanding - I'm not sure where your issue is?  Also what OPC Library are you using? 

A client GUIs may/often allow a user to enter a time in a local time zone and then convert it to UTC for use through out the system, but this would be part of the client functionality.  Any data that is returned, if the time stamp is to be displayed, then again the conversion would be perform for the display.  i.e. a client GUI may want to display all time in the Local time, but this is only on the client GUI.

Paul Hunkar - DSInteroperability

Avatar
Santosh
Member
Members
Forum Posts: 6
Member Since:
07/10/2023
sp_UserOfflineSmall Offline
3
09/22/2025 - 07:27
sp_Permalink sp_Print sp_EditHistory

We are using the .NET Standard OPC Library for this implementation.

Please find the attached screenshots for reference. Up to the point where the client communicates with the OPC Library, the values remain the same as what the client is sending. However, when we trace the request using Wireshark, we notice that the values are automatically converted to the local time zone. This seems to be happening because the client is running in a different time zone.

Avatar
Randy Armstrong
Admin
Forum Posts: 1656
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
4
09/22/2025 - 21:40
sp_Permalink sp_Print

If you are using .NET there is a flag in DateTime class that called DateTimeKind. It has to be set to UTC on all values passed to the API.

Avatar
Santosh
Member
Members
Forum Posts: 6
Member Since:
07/10/2023
sp_UserOfflineSmall Offline
5
09/22/2025 - 23:36
sp_Permalink sp_Print sp_EditHistory

Hi Armstrong,

Thank you for your response.

I’ve updated the code to explicitly specify DateTimeKind as UTC. However, I’m still encountering the same error.

Could you please advise on the next steps to help resolve this?

Avatar
Randy Armstrong
Admin
Forum Posts: 1656
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
6
09/23/2025 - 06:31
sp_Permalink sp_Print

Can you provide a link to the source of the library you are actually using?

Avatar
Santosh
Member
Members
Forum Posts: 6
Member Since:
07/10/2023
sp_UserOfflineSmall Offline
Avatar
Randy Armstrong
Admin
Forum Posts: 1656
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
8
09/24/2025 - 01:20
sp_Permalink sp_Print

What exact APIs are you using to send history requests?

Avatar
Santosh
Member
Members
Forum Posts: 6
Member Since:
07/10/2023
sp_UserOfflineSmall Offline
9
09/24/2025 - 01:56
sp_Permalink sp_Print

public override ResponseHeader HistoryRead : this call is from SessionClientBatched.cs file

Avatar
Randy Armstrong
Admin
Forum Posts: 1656
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
10
09/25/2025 - 00:07
sp_Permalink sp_Print

The code makes this call before writing to the wire:

value = Utils.ToOpcUaUniversalTime(value);

Can you do some testing with that API and to determine if there is either a problem with your input or a problem with the function.

Avatar
Santosh
Member
Members
Forum Posts: 6
Member Since:
07/10/2023
sp_UserOfflineSmall Offline
11
09/25/2025 - 01:14
sp_Permalink sp_Print

Hi Randy,

We have seen this code and found that there is no problem in this.

found that the value is converting from 636188622030000000 to different value in public void WriteDateTime(string fieldName, DateTime value) which is under BinaryEncoder.cs file. which writes the values to m_writer.Write(ticks);.

We are confused if this value conversion is causing any problem.

Avatar
Randy Armstrong
Admin
Forum Posts: 1656
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
12
10/03/2025 - 01:41
sp_Permalink sp_Print

It is not clear where the changing is occurring.

The ticks from the value returned from ToOpcUaUniversalTime are what is put on the wire.

Forum Timezone: America/Phoenix
Most Users Ever Online: 510
Currently Online:
Guest(s) 38
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Forum Stats:
Groups: 2
Forums: 10
Topics: 1508
Posts: 5103