Binary-Time string format specification

A TwinCAT Binary-Time string has a max. length of 26 characters and the following structure: ‘BT#[YYYY-MM-DD-]hh:mm:ss[.n[n[n]]]‘.

Using the conversion function String_To_BinaryTime6, the Binary-Time information, which is formatted as a string, can easily be converted into the components of the structured type T_BinaryTime. The date is converted into the "day" component (2 bytes) and the time into the "timeOfDay" component (4 bytes).

The date in the Binary-Time string is optional and need not be specified. If the date was not specified, then the string is a 4-byte Binary-Time format (only the "timeOfDay" component). In this case the value 0 is implicitly assigned during the conversion of the "day" component (this corresponds to the date 1984-01-01). A string with date is a 6-byte Binary-Time format ("timeOfDay" and "day" component).

Variable

Representation

Value range

Description

Prefix

BT#

‘BT#‘

Constant prefix.

Year

YYYY

‘1984‘..‘2106‘

Year (4 decimal places, optional).

Month

MM

‘01‘..‘12‘

Month (2 decimal places, optional).

Day

DD

‘01‘..‘31‘

Day (2 decimal places, optional).

Hour

hh

‘00‘..‘23‘

Hour (2 decimal places).

Minute

mm

‘00‘..‘59‘

Minute (2 decimal places).

Second

ss

‘00‘..‘59‘

Second (2 decimal places).

Millisecond

n[n[n]]]

‘‘,‘0‘..‘999‘

Millisecond (0 to 3 decimal places, optional).

Samples

The table below contains some strings and the values of the components after conversion to the structured type T_BinaryTime.

STRING(26)

T_BinaryTime

‘BT#1984-01-01-00:00:00‘

STRUCT(timeOfDay:=TOD#00:00:00, day:=0)

‘BT#2018-03-04-11:12:55.6‘

STRUCT(timeOfDay:=TOD#11:12:55.600, day:=16#30C1)

‘BT#2018-03-04-11:12:55.678‘

STRUCT(timeOfDay:=TOD#11:12:55.678, day:=16#30C1)

‘BT#01:02:03‘

STRUCT(timeOfDay:=TOD#01:02:03, day:=0)

‘BT#01:02:03.5‘

STRUCT(timeOfDay:=TOD#01:02:03.500, day:=0)

‘BT#01:02:03.567‘

STRUCT(timeOfDay:=TOD#01:02:03.567, day:=0)