OPC Tag Timestamp to Milliseconds?

Hello, we have some boolean OPC UA tags and we want to get the alarm timestamps configured on these tags down the the millisecond. This is possible in our legacy SCADA (PSO) systems, but I'm not sure where that configuration would exist. These are MMS points with value, timestamp, and quality being reported.

Timestamps do include milliseconds, but you may be viewing them somewhere that they are formatted without them.

Give us some more context about what you're doing and where you're viewing these timestamps.

I'm viewing the tag Timestamp directly in the tag browser. Would they get formatted there as well?

Yeah, the Tag Browser just uses the default Java date format, which is something like EEE MMM dd HH:mm:ss zzz yyyy in terms of format strings. It does not include millis.

The millisecond data is there under the hood when needed, though.

1 Like

Got it! I see, I was able to reveal the granularity under the hood. Thank you Kevin!

tag = system.tag.readBlocking('[TagProvider]HeartbeatInstance/Heartbeat.Timestamp')
timestamp = tag[0].value
timestamp = system.date.format(timestamp, "yyy-MM-dd HH:mm:ss:SSS")

print(timestamp)
>>> 
2023-05-09 16:46:14:850

You can also get greater granularity revealed directly on the tag value by adjusting the 'Format String' field in the tag properties to include the desired Date Type Formatting:

image