TIME/TOD_TO_<type>
This IEC operator converts from the data type TIME or TIME_OF_DAY (TOD) to a different data type.
Syntax: <TIME data type>_TO_<data type>
TwinCAT internally stores the time in a DWORD in milliseconds (for TIME_OF_DAY since 00:00). TwinCAT converts this value. With the data type STRING the result is the time constant.
Information may be lost during type conversion from larger to smaller data types. |
Samples:
ST code | Result |
---|---|
sVar := TIME_TO_STRING(T#12ms); | T#12ms |
nVar := TIME_TO_DWORD(T#5m); | 300000 |
nVar := TOD_TO_SINT(TOD#00:00:00.012); | 12 |
FBD code | Result |
---|---|
T#12ms | |
300000 | |
12 |
See also:
- Data types > Date and time data types