//Reads the PLC date and time and converts it to a string value
//Read PLC Date Time. Write to DateTime in Controller Tags as usual DINT[7] format.
GSV(WallClockTime,,DateTime,PLC_Time[0]);
//Convert Year to String
DTOS(PLC_Time[0],YearString);
//Convert Month to String // Add leading zero if less than 10
If PLC_Time[1] >=10 Then
DTOS (PLC_Time[1],MonthString);
ELSE DTOS (PLC_Time[1],MonthTemp);
CONCAT (strConst[4],MonthTemp,MonthString);
END_IF;
//Convert Day to String // Add leading zero if less than 10
If PLC_Time[2] >=10 Then
DTOS (PLC_Time[2],DayString);
ELSE DTOS (PLC_Time[2],DayTemp);
CONCAT (strConst[4],DayTemp,DayString);
END_IF;
//Convert Hour to String // Add leading zero if less than 10
If PLC_Time[3] >=10 Then
DTOS (PLC_Time[3],HourString);
ELSE DTOS (PLC_Time[3],HourTemp);
CONCAT (strConst[4],HourTemp,HourString);
END_IF;
//Convert Minute to String // Add leading zero if less than 10
If PLC_Time[4] >=10 Then
DTOS (PLC_Time[4],MinuteString);
ELSE DTOS (PLC_Time[4],MinuteTemp);
CONCAT (strConst[4],MinuteTemp,MinuteString);
END_IF;
//Convert Second to String // Add leading zero if less than 10
If PLC_Time[5] >=10 Then
DTOS (PLC_Time[5],SecondString);
ELSE DTOS (PLC_Time[5],SecondTemp);
CONCAT (strConst[4],SecondTemp,SecondString);
END_IF;
//Merged all the strings together
CONCAT(DayString, strConst[1], stTemp[0]); //Add Bracket to Day
CONCAT(stTemp[0], MonthString, stTemp[1]); //Add Month
CONCAT(stTemp[1], strConst[1], stTemp[2]); //Add Bracket
CONCAT(stTemp[2], YearString, stTemp[3]); //Add Year
CONCAT(stTemp[3], strConst[0], stTemp[4]); //Add Space
CONCAT(stTemp[4], HourString, stTemp[5]); //Add Hour
CONCAT(stTemp[5], strConst[2], stTemp[6]); //Add Colon
CONCAT(stTemp[6], MinuteString, stTemp[7]); //Add Minute
CONCAT(stTemp[7], strConst[2], stTemp[8]); //Add Colon
CONCAT(stTemp[8], SecondString, stTemp[9]); //Add Second
//Copy the DateTime string to the Controller Tag
COP(stTemp[9], Date_Time_String, 1);