Navigation:  Equipments (Devices) > PLC200 > Program > Conversion > DATETIME >

DATETIME_TO_EPOCH

Previous pageReturn to chapter overviewNext page

Block that converts a date and time value to the EPOCH format.

 

Ladder Representation

 

D2E_G0

 

Block Structure

 

Variable Type

Name

Data Type

Description

VAR_INPUT

EN

BOOL

Block enabling

Second

BYTE

Seconds

Minute

BYTE

Minutes

Hour

BYTE

Hours

Day

BYTE

Days

Month

BYTE

Months

Year

WORD

Years

VAR_OUTPUT

ENO

BOOL

End of operation

Result

DWORD

Value in EPOCH

 

Operation

 

When this block has a TRUE value in EN, it interprets the date and time values and converts them to EPOCH, storing in Result.

 

When EN has FALSE value, Result remains unchanged.

 

The ENO value forwards to the next Ladder block the EN value after the operation is completed.

 

Example in Ladder

 

DATETIME_TO_EPOCH_example01

 

The example above converts the date and time to EPOCH (DWORD) format, storing the final result in RESULT. The block ends with success, and the ENO output is activated.

 

Example in ST

 

 The example below displays instructions for applying the example above in ST language.

 

 

VAR

   enable : BOOL := 1;

   done : BOOL;

   sec : BYTE := 30;

   min : BYTE := 30;

   hour : BYTE := 12;

   day : BYTE := 15;

   month : BYTE := 6;

   year : WORD := 2030;

   epoch : DWORD;

END_VAR

 

done := FB_DATETIME_TO_EPOCH(EN:=enable, Second:= sec, Minute:=min, Hour:=hour, Day:=day, Month:=month, Year:=year, Result=> epoch);