@chi, I was trying to use your piece of code to read the time but can’t seem to understand exactly !
So, When I get the DATE and TIME in millis, at this point of time they are 11235 and 43640750 respectively. Now, from what you have., I understand that you want to shift binary of DATE to left by 32 bits to get the millis of date and then add millis of time into it. However, when I shift 32 bits left, my value is way too big (approx 188,535,312,519). Now, that value goes into the tag change event script and executed with binary. But, what comes out is nowhere close to current time.
Is there any reference to understand the DATETIME and binary conversion ?
This thread is about a special datatype in legacy Siemens plcs. Look at the first post for a description of that type.
Where did you get the values 11235 and 43640750 from? They don’t seem to be a date/time format i recognize.
From the original question I understand that the requirement is to read (and write) time to PLC. The PLC I am using is S7-300 with Simatic Manager.
As per the picture below, I have created DB tags to store both TOD(Time_Of_Day) and DATE(Which both seems to be in millisecond format). Now, I am trying to read this in Ignition by creating 2 different tags and combining them with expression but, it doesn’t seem to work.
Check the datatypes in the Siemens manuals. The original question in this thread is about the DATE_AND_TIME type.
You are using TOD, a 32 bit unsigned integer with milliseconds since midnight. DATE is 16 bit unsigned integer with days since 1990-01-01.
To convert it to a java time (milliseconds since 1970-01-01) you have to do some math (untested!):
631152000000+(DATE*24*60*60*1000)+TOD
# 631152000000 = milliseconds from 1970-01-01 to 1990-01-01
Hi, I came across this in the manual. It seems that you can get the date_and_Time format via the Siemens driver.
But a guess the only applies for the driver and not when you are using the OPC server interface in the Siemens PLC to access the tags?
Or am I'm missing something!