Documentation

Time+Date to Total Seconds (B97)

Conversion of Time/Date to seconds

Block name

B97_TIME_DATE_TO_TOTAL_SECONDS

ST call

PROGRAM TEST_B97
VAR
SINT1,SINT2,SINT3,SINT4,SINT5,SINT7 :SINT;
INT6:INT6;
UDINT1: UDINT;
FB: LIB.CORE.V1_0.B97_TIME_DATE_TO_TOTAL_SECONDS;
END_VAR
FB(SEC:= SINT1, MIN:= SINT2,HOUR:=SINT3,DAY:=SINT4,MON:=SINT5,YEAR:=INT6,TOT=>UDINT1,WDAY=>SINT7);
END_PROGRAM

Library

LIB\CORE

Version

V1.0

Description

The block converts time and date to total seconds (starting at 1.1.1970, 0:00). Another output is the current weekday.

Inputs

Input Type Description Default value
SEC SINT Seconds 0
MIN SINT Minutes 0
HOUR SINT Hours 0
DAY SINT Days 0
MON SINT Months 0
YEAR INT Years 0

Outputs

Output Type Description
TOT UDINT Number of seconds since 1.1.1970, 00:00 UTC
WDAY SINT Weekday (0 = Sun, 1 = Mon, ..., 6 = Sat)

Function

The block converts time and date to total seconds (starting at 1.1.1970, 0:00). Another integer output, wday, defines the current day of week (0 = Sunday, 1 = Monday, ..., 6 = Saturday). For example, 1.1.1970 01:00 – one hour after the reference time start (i.e. sec=0, min=0, hour=1, day=1, mon=1, year=1970) - the outputs are tot=3600, and wday=4.

Application example

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