DTSetDateTime

 Function Block - Sets the local date and time.

This function block is specific for PCMM2G only.

Inputs


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

Input

Data Type

Range

Unit

Default

Description

Execute

BOOL

FALSE, TRUE

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.

Minute

DINT

0 to 59

Minute

No default

The local date’s new value of the minute.

Second

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.

Outputs

Output

Data Type

Range

Unit

Description

Done

BOOL

FALSE, TRUE

N/A

If TRUE, the command completed successfully.

Error

BOOL

FALSE, TRUE

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

  • 23 = Internal error.
    See the controller log for details.
  • 15000 = Controller type does not support this function block.
  • 16202 = Cannot set date / time when NTP synchronization is active.
  • 16203 = Invalid date / time value specified.

Remarks

None

FBD Language Example

FFLD Language Example

IL Language Example

Not available.

ST Language Example

// 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