DTSetDateTime

 Function BlockClosed A function block groups an algorithm and a set of private data. It has inputs and outputs. - Sets the local date and time.

This function block is specific for PCMM2G only.

Inputs

Input

Data Type

Range

Unit

Default

Description

Execute

BOOL

TRUE, FALSE

N/A

No default

If TRUE, request to set the local date and time.

Year

DINT

1900 to 2200

Year

No default

The local date’s new value of the year.

Month

DINT

1 to 12

Month

No default

The local date’s new value of the month.

Day

DINT

1 to 31

Day

No default

The local date’s new value of the day.

Hour

DINT

0 to 23

Hour

No default

The local date’s new value of the hour.

Min

DINT

0 to 59

Minute

No default

The local date’s new value of the minute.

Sec

DINT

0 to 60

Second

No default

The local date’s new value of the second.


  • 60 is valid because leap seconds may have a value of 60.

  • If the UTC time needs to be set, change the time zone to UTC using DTSetTimeZone, set the time, then restore the time zone.

Outputs

Output

Data Type

Range

Unit

Description

Done

BOOL

TRUE, FALSE

N/A

If TRUE, the command completed successfully.

Error

BOOL

TRUE, FALSE

N/A

If TRUE, an error has occurred.

ErrorID

DINT

No range

N/A

Indicates the error if the Error output is set to TRUE.

Error Codes

Remarks

None

FBD Language

FFLD Language

IL Language

Not available.

ST Language

// write the date and time
Inst_DTSetDateTime( bSetDateTime, Year, Month, Day, Hour, Minute, Second );
if Inst_DTSetDateTime.Done then
   bSetDateTime := false;

   bError := Inst_DTSetDateTime.Error;
   ErrorID := Inst_DTSetDateTime.ErrorID;
end_if;

See Also