Operator ‘TIME_TO/TIME_OF_DAY_TO’

This IEC operator is used for converting the TIME and TIME_OF_DAY data types into another data type.

<TIME data type>_TO_<data type>

Internally, CODESYS saves the time (in milliseconds) to a DWORD (for TIME_OF_DAY since 00:00). CODESYS converts this value.

For the STRING data type, the result is the time constant.

Attention

Information can be lost when converting from larger data types to smaller data types.

Examples

ST Code Result
str := TIME_TO_STRING(T#12ms); T#12ms
dw := TIME_TO_DWORD(T#5m); 300000
si := TOD_TO_SINT(TOD#00:00:00.012); 12
FBD Code Result
../_images/519745b9d05263f2c0a8640e01d85b15 T#12ms
../_images/8ae88e90d050320ac0a8640e009c12cc 30000
../_images/f09e60b0d053c1b5c0a8640e0097fa94 12