I want to convert hour to seconds but unsigned long is overflowing, here's the code:
#include <Wire.h>
#include <DS3231.h>
RTClib myRTC;
unsigned long seconds;
char timestr[9];
void setup() {
Serial.begin(250000);
Wire.begin();
}
void loop() {
DateTime now = myRTC.now();
snprintf(timestr, 9, "%02d:%02d:%02d", now.hour(), now.minute(), now.second());
seconds = (now.hour() * 3600);
Serial.println(timestr);
Serial.println(seconds);
delay(100);
}
And the console output is:
16:33:36
4294959360
Why is this happening?