Time stamp adjustments
- Last UpdatedMay 21, 2025
- 3 minute read
PI Interface for OPC DA does not adjust the time stamps it receives, regardless of the time zone settings or ts parameter specified in the batch file. Any scaling or transformation is performed after the string has been translated into seconds, which enables a wide range of values to be handled.
There are two different types of time stamps:
-
Windows type time stamp
This time stamp type accompanies item values and is defined as a UTC time.
-
VT_DATE or other variant type (VT_*)
This is an item value type that can represent a date, time, or combination of the two. Items that contain a VT_DATE value are interpreted as local time with no daylight savings adjustments. Item values that contain a VT_BSTR (string) representation of a date or time have no specification for the presumed time zone; the OPC server has the option of local time or UTC.
Time stamp to seconds
To store a time stamp string (VT_BSTR) as seconds, set location2 to 6.
If the PI point is an integer, PI Interface for OPC DA attempts to translate the time stamp into whole seconds. Because Int16 points can only hold numbers up to 32767, use Int32 points for time spans longer than nine hours.
If the PI point has a floating-point data type, the time stamp is translated into seconds and stored as a floating-point number.
Time stamps as VT_DATE data types
The OPC standard allows the VT_DATE data type, which is an internal representation of a time stamp. PI Interface for OPC DA translates between VT_DATE and integer, float, or string points. The interface does not adjust the time stamps received, regardless of the time zone settings.
To configure PI Interface for OPC DA to use the VT_DATE data type for reading the value from the OPC server or for writing the value to output points, set location2 to 7.
For string points, the time stamp format of the string must be specified using the tf command-line parameter.
Time stamp strings
To configure the format of the time stamp sent by the OPC server using PI ICU, go to the OPCInt > Data Handling page and specify the format in the Format of Timestamp Strings field using the following tokens:
|
Time stamp token |
Description |
|---|---|
|
cc |
Two-digit century |
|
yy |
Two-digit year |
|
mn |
Two-digit month |
|
mon |
Three-character month (Jan Feb Mar, etc.) |
|
dd |
Two-digit day |
|
hh |
Two-digit hour from 0 to 23 |
|
hr |
Two-digit hour from 0 to 12 |
|
mm |
Two-digit minute |
|
ss |
Two-digit second |
|
000 |
Three-digit milliseconds |
|
XM |
AM or PM |
The position of the tokens and delimiters must specify the format of the time stamp string precisely. Examples:
|
Format String |
Result |
|---|---|
|
ccyy/mn/dd hh:mm:ss.000 |
1998/11/29 15:32:19.391 |
|
dd mon, ccyy hr:mm:ss XM |
29 Nov, 1998 03:32:19 PM |
|
mn-dd-ccyy hh:mm:ss |
11-29-1998 15:32:19 |
|
hh:mm:ss.000 |
15:32:19.482 |
Only one format string can be specified for each instance of PI Interface for OPC DA. If more than one format of time stamp needs to be processed, configure additional instances of the interface with the required time stamp format string.
If you omit elements of the format strings, the defaults are as follows ("current" values are UTC):
|
Omitted format string element |
Default |
|---|---|
|
Day |
Current day |
|
Month |
Current month |
|
Year |
Current year |
|
Century |
Current century |
Note: If you specify only hours, minutes and seconds, the date defaults to January 1, 1970. To ensure accurate time stamps, be sure to specify all the elements of the time stamp format. If the OPC server returns a zero value for the day, month or year element, the interface applies the defaults described above, regardless of the format string you specify.