
07/28/2015

I am using a library based on twenty-year-old but still-working sample code to read OPC data. My data point has a timestamp of 132514957825255872. When I use “DateTime theTime = new DateTime(timestamp)”, I get a date/time of 12/3/0420 7:03:02 PM. That is exactly 1600 years and five hours away from the correct time. In C#, an integer being converted to a timestamp is assumed to be the number of 100-nanosecond ticks since 1/1/0001 00:00:00. It appears that the number I am getting from my OPC server (KEPWare’s KEPServerEX, if it matters) is the number of 100-nanosecond ticks since 1/1/1600 00:00:00 in UTC time. Is that correct?

05/30/2017

The 0 time for the .NET DateTime is January 1, 0001 at 00:00:00.000 in the Gregorian calendar.
The 0 for COM DA and OPC UA is 12:00 A.M. January 1, 1601 Coordinated Universal Time (UTC)
The OPC UA .NETStandard codebase has a constant Utils.TimeBase that can be used for adjustment.

02/22/2021

You probably are encountering an issue with FILETIME structure was incorrectly written in C#, see this link
https://github.com/dotnet/runt…..sues/28700
I have modified my version of OPC Net API so that it uses uint vs int, like:
namespace OpcRcw.Da
{
using System;
using System.Runtime.InteropServices;[StructLayout(LayoutKind.Sequential, Pack=4)]
public struct FILETIME
{
public uint dwLowDateTime;
public uint dwHighDateTime;
}
}
Of course you have to make changes to other locations for proper conversion.
1 Guest(s)