Function Block T2STR

The Function Block T2STR converts a time into a string.

Input PT

Defines the time in T# for calculating the string.

Input FORMAT

The format is defined as a string at the input. For example, "%m" for minutes. If no input is set or left empty, the string "%dd %hh %mm %ss %msms" is assumed.

Possible Values
Format Output
%d Days, e.g.: 1
%%d Days with leading zero, e.g.: 01
%h Hours, e.g.: 5
%%h Hours with leading zero, e.g.: 05
%m Minutes, e.g.: 2
%%m Minutes with leading zero, e.g.: 02
%s Seconds, e.g.: 4
%%s Seconds with leading zero, e.g.: 04
%ms Milliseconds, e.g.: 6
%%ms Milliseconds with leading zero, e.g.: 06
%%%ms Milliseconds with leading double zero, e.g.: 006

Input MAXRES

The input defines the maximum resolution of the Function Block in the format T#. All variables that are higher than this value will be returned as 0 and added to the previous value. A value of T#1h, for example, will return 73m 4h 12s.

Tip: The minimum resolution can be generated with the Function Block MOD, by modifying the input PT beforehand.

Output STR

Returns the string in the specified format.

Replacing 0d 0h 0m 0s 0ms

The zero values can be easily replaced with the Function Block PREG_REPLACE. To do this, '/\b0(?:ms|d|h|m|s)\b\s*/' is used at the input PATTERN and the output STR is connected to the input SUBJECT. The result can leave spaces. These can be removed using the Function Block STR_TRIM.