I'm trying to load a string variable named timeStr with time "hh:mm:ss mm/dd/yyyy".
Sounds simple, but after the second element, it blows up on compile.
Here is the context:
String timeStr;
if (RTC.read(tm)) {
// Serial.print("Ok, Time = ");
print2digits(tm.Hour);
Serial.write(':');
print2digits(tm.Minute);
Serial.write(':');
print2digits(tm.Second);
Serial.print(" ");
Serial.print(tm.Day);
Serial.write('/');
Serial.print(tm.Month);
Serial.write('/');
Serial.print(tmYearToCalendar(tm.Year));
Serial.println();
timeStr = tm.Hour + ":" + tm.Minute + ":" + tm.Second + " " + tm.Month + "/" + tm.Day + "/...");
With the 'timeStr = ' line terminated after tm.Minute, compile is fine. But any additional elements result in this error.
The error is:
invalid operands of types 'const char*' and 'const char [2]' to binary 'operator+'
Any advice greatly appreciated.