Datasheet

Because this is not an especially unlikely occurrence - particularly if you're querying the time pretty often - we take a
'snapshot' of the time from the RTC all at once and then we can pull it apart into day() or second() as seen above. Its a
tiny bit more effort but we think its worth it to avoid mistakes!
We can also get a 'timestamp' out of the DateTime object by calling unixtime which counts the number of seconds (not
counting leapseconds) since midnight, January 1st 1970
Since there are 60*60*24 = 86400 seconds in a day, we can easily count days since then as well. This might be useful
when you want to keep track of how much time has passed since the last query, making some math a lot easier (like
checking if its been 5 minutes later, just see if unixtime() has increased by 300, you dont have to worry about hour
changes).
Serial.print(" since midnight 1/1/1970 = ");
Serial.print(now.unixtime());
Serial.print("s = ");
Serial.print(now.unixtime() / 86400L);
Serial.println("d");
© Adafruit Industries https://learn.adafruit.com/adafruit-ds3231-precision-rtc-breakout Page 16 of 22