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.

TIME/TOD_TO_<type> 1:

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

TIME/TOD_TO_<type> 2:

T#12ms

TIME/TOD_TO_<type> 3:

300000

TIME/TOD_TO_<type> 4:

12

See also: