RTC Class of time, how to use it in conditional argument

I have made a sketch to experiment with DS 3231 RTC modules and want to have the “Month” in the conditional
argument of an IF function.
I can make it work with “day, hour and minute” but when I enter " month" and error message " Not a class of time from the RTC. or something to that regard.
Even though I can display the month on the LCD.
Suggestions on how to use this , would be appreciated

// Sketch to give an Output to control SSR shown here as ledPin for Output
// To be changed to Output for SSR

#include <DS3231.h> A
#include <LiquidCrystal.h>
DS3231 rtc(SDA, SCL);
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
Time t;
const int OnDay =1;
const int OnMonth =8;
const int OffDay =3;
const int OffMonth =8;
const int OnHour = 0; //SET TIME TO TURN ON RELAY (24 HOUR FORMAT)
const int OnMin = 0;
const int OffHour = 0; //SET TIME TO TURN OFF RELAY
const int OffMin = 1;
const int Led = 10; // To be Changed for Output to SSR
const int ledPin = LED_BUILTIN;

void setup() {
lcd.begin(16, 2);
rtc.setDOW(MONDAY); // Set Day-of-Week to (*)
rtc.setTime(23, 59, 50); // Set the time to 12:00:00 (24hr format)
rtc.setDate(31, 7, 2019); // Day, Month, Year
pinMode(ledPin, OUTPUT); // Output
digitalWrite(ledPin, LOW); // Standby status

void loop() {
lcd.setCursor(0, 0);

lcd.setCursor(0, 1);
lcd.print("Time: ");

lcd.setCursor(0, 1);
lcd.print("Date: ");

lcd.setCursor(0, 1);
lcd.print("Day: “);
lcd.print(” ");

lcd.setCursor(0, 1);
lcd.print("Month: “);
lcd.print(” ");

t = rtc.getTime();
if ( t.date == OnDay && t.hour == OnHour && t.min == OnMin) { // Condition to turn on Output
digitalWrite(ledPin, HIGH);
digitalWrite(10, HIGH); // Red LED to show output active
lcd.setCursor(0, 1);
lcd.print("SSR ON “);
lcd.print(” ");

else {

digitalWrite(ledPin, LOW);
digitalWrite(10, LOW);
lcd.setCursor(0, 1);
lcd.print("SSR OFF “);
lcd.print(” ");


There are several DS3231 libraries with the same name. If yours is the one from RinkyDinkElectronics, then getMonthStr() provides a char array. It can be of 2 different formats, depending on the argument of getMonthStr.

Calling getMonthStr(FORMAT_SHORT) will provide these values :

	char *monthShort[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};

Calling getMonthStr() or getMonthStr(FORMAT_LONG) these :

char *monthLong[]  = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};

Furthermore, to answer your question, you need to test using t.mon
as the class Time is defined as

class Time
uint8_t hour;
uint8_t min;
uint8_t sec;
uint8_t date;
** uint8_t mon;**
uint16_t year;
uint8_t dow;


t.mon gives the months since January in the form 0-11

First: edit your post and insert code tags. The sticky post at the top of the topic explains how to do that!

I can make it work with "day, hour and minute" but when I enter " month" and error message " Not a class of time from the RTC. or something to that regard.

The exact error message is usually needed.

Let me guess: the posted code compiles correctly and you don't want to show us the code that produces the error message.

Post a link to the used RTC library as the DS3231.h library I have installed doesn't have a getTime() method.

Thanks Lesept i'll give that a try just learning and experimenting with this RTC module to use in later project.

Pylon your correct I should have included the error that I received, I will be more precise in further postings.

The only change in code was that I had included into the conditional argument (t.month == OnMonth && Etc. Etc.

When I got the error message I deleted that part and tried again and then posted my question to the Forum.

The only change in code was that I had included into the conditional argument (t.month == OnMonth

The month field is called "mon" and not "month" (given you use the library lesept linked to as you still didn't provide a link).

Thanks for the info and yes I did use the DS3231 library from RinkyDinkElectronics.
Looked at their site and will download the info provided there.