FB_TzSpecificLocalTimeToFileTime64 1:

The function block converts the local time (file time format) to UTC time (file time format), taking into account the specified time zone information. The function block: FB_TzSpecificLocalTimeToSystemTime has a similar function, the difference being that it converts to a different time format (structured system time format).

The function block is only suitable for conversion of continuous local timestamp information. Step changes in local time caused by summer/winter time changeover are permitted and are correctly detected by the function block. Arbitrary changes in local time result in incorrect conversion. The reason: the last converted time is stored internally in function block in order to be able to identify the summer time/winter time information and the B times (see below) when the local time is reset. The function block is associated with an action: A_Reset(). If this action is called the function block outputs and the locally stored (last converted) time are reset to zero.

The step changes in the local time are problematic, since they have to be converted to a linear UTC time. It is therefore advisable to use the (continuous) UTC time for time stamping tasks and to convert the time to respective local time only for display purposes (e.g. in a visualization).

1. Graphic representation of the changeover from summer time to winter time (tzInfo = WEST_EUROPE_TZI ):

FB_TzSpecificLocalTimeToFileTime64 2:

The local time (green) jumps back. The UTC output time (red) continuous. The local time: 02h:59m:59s:999ms.. is directly followed by: 02h:00m:00s:000ms.. The times between 2h and 3h occur twice. The duplicate time before the changeover is referred to as 02:05:00 CEST A, for example, the time after the changeover as 02:05:00 CET B. The output variable bB indicates whether it is the first or the second pass. During the second pass the bB output variable (blue) is set to TRUE. The bB output variable is automatically reset once the duplicate time has passed. The time zone ID (orange) changes from eTimeZoneID_Daylight (summer time) to eTimeZoneID_Standard (winter time).

2. Graphic representation of the change-over from winter time to summer time (tzInfo = WEST_EUROPE_TZI):

FB_TzSpecificLocalTimeToFileTime64 3:

The local time (green) jumps forward. The UTC output time (red) continuous. The local time: 2h:59m:59s:999ms.. is directly followed by: 3h:00m:00s:000ms.. The time zone ID (orange) changes from eTimeZoneID_Standard (winter time) to eTimeZoneID_Daylight (summer time).


    in     : T_FILETIME64;
    tzInfo : ST_TimeZoneInformation;

in: Local time (file time format) that is to be converted (type: T_FILETIME).

tzInfo: Structure variable with the current time zone information of the operating system (type: ST_TimeZoneInformation).


    out   : T_FILETIME64;
    eTzID : E_TimeZoneID := eTimeZoneID_Unknown;
    bB    : BOOL;

out: Converted UTC time (file time format) (type: T_FILETIME64).

eTzID: Additional summer/winter time information (type: E_TimeZoneID).

bB: TRUE => B-time (e.g.:02:05:00 CET B), FALSE => remaining time (e.g.: 02:05:00 CEST A). This output is set if the local time jumps back and is reset once the duplicate local time has passed.


The local time: DT#2011-09-02-11:01:31 is converted into UTC time: DT#2011-09-02-09:01:31.

    in      : DT := DT#2011-09-02-11:01:31;(* Local time *)
    out     : DT;(* UTC time *)
    fbToUTC : FB_TzSpecificLocalTimeToFileTime64;
fbToUTC( in := DT_TO_FILETIME64( in ), tzInfo := WEST_EUROPE_TZI );
out := FILETIME64_TO_DT( fbToUTC.out );

Further time and time zone functions and function blocks:


Development environment

Target platform

PLC libraries to be integrated (category group)

TwinCAT v3.1.4024

PC or CX (x86, x64, ARM)

Tc2_Utilities (System) >=