Table of Contents

Conversion of Seconds to Time/Date

Block name

B98_TOTAL_SECONDS_TO_TIME_DATE

ST call

PROGRAM TEST B98
   VAR
 SINT1,SINT2,SINT3,SINT4,SINT5,SINT7: SINT;
  INT6,INT8: INT;     
    FB : LIB.CORE.V1_0.B98_TOTAL_SECONDS_TO_TIME_DATE;
  END_VAR
 FB(IN:=GETLOCALTIME(),SEC=>SINT1,MIN=>SINT2,HOUR=>SINT3,DAY=>SINT4,MON=>SINT5,YEAR=>INT6,WDAY=>SINT7,REAMINDAY=>INT8);
END_PROGRAM

Library

LIB\CORE

Version

V1.0

Description

The block converts the total seconds starting at 1.1.1970, 0:00, to seconds, minutes, hours etc.

Inputs

InputTypeDescription
IN DT Input of DateTime value

Outputs

Output TypeDescription
SEC SINTSeconds
MIN SINTMinuted
HOUR SINTHours
DAY SINTDays
MON SINTMonths
YEAR INT Years
WDAY SINTDay of week (0 = Sunday, 1 = Monday, …, 6 = Saturday)
REMAINDAYINT Days remaining until the end of the month (last day: remainday = 0)

Function

The block converts the total time in (starting at 1.1.1970, 00:00), into other units The resulting outputs are sec, min, hour, day, mon, and year. For example, for in=3600 the outputs are sec=0, min=0, hour=1, day=1, mon=1, year=1970. Apart from this, the wday output shows the day of week (0 = Sunday, 1 = Monday, …, 6 = Saturday).

Note that the input values are in UTC format. If in < 0 then it is supposed that in = 0.

Application example


The block, together with B97, is used as an auxiliary block for various time/date conversions, calculating of time spans etc.