Comparing time to a constant time

I have a DS3231 and I want to reset a variable to 0 at noon. I get how to reset the variable but have not been able to make the if statement work. This is what I am going for below. Let me know where I am going wrong. Thank you,

if (rtc.getTimeStr(1) == "12:00"; {
variable = 0
}

Post ALL the code, after making sure that it compiles without errors. That won't.

  1. You can't compare a variable to a character string in the way you are attempting, unless it is a String. We strongly discourage use of String objects, because they often cause the Arduino to crash. For the recommended C-strings (zero terminated character arrays), use the function strcmp().

  2. It is a bad idea to compare exact times, because you may not read the clock at the correct moment. Instead, use minutes or seconds past midnight and a ">=" numerical comparison.

What do you mean when you write that you cannot make the if statement work? THAT is not how to write an if statement. You do not get to invent your own way of writing things. An if statement should look more like this:

if (rtc.getTimeStr(1) == "12:00") {
variable = 0 ;
}

Because this is just a snippet of code, I do not know what rtc is and I do not know what a parameter of 1 does and I do not know what getTimeStr(...) returns.

Furthermore, that is not the correct way to compare C strings. My mobile device makes it difficult to show you the correct way.

On the other hand, == may work with String (capital S) but the usual advice is to avoid String on an Arduino.

OK so I found this example that I edited to work for my application. Turn on and off relay at certain times

So, the sketch will set that variable to zero continuously for the entire duration of the minute after noon.

OK, perhaps you started with an example but you are attempting some things that are NOT in the example.