How to extract Unix timestamp from tag read?

Hi everyone,

How can I get the unix timstamp out of this return from a command?

## Call
path ="[]MyTagPath")
print path

## Return
[1737.9868, Good, Sat Jun 18 16:56:10 CDT 2022 (1655589370000)]

## Preferred Return
1655589370000 gives me the ordinary date time format and I’m struggling to convert it to unix in the script console.

Thank you,

Try this in the Script Console.

path ="[]MyTagPath")
print type(path)
print path.getValue()
print path.getTimestamp()

You can read more about the data type here:

Someone else may have a more terse solution.

1 Like

The timestamp you get from a QualifiedValue is a java.util.Date, on which you can call getTime().


Thank you both! For others, here is an example of the result.

## Call
reading_time ="[]MyTagPath")
print reading_time.timestamp.getTime() / 1000

## Result