The library is the RTClib from Adafruit version 2.0.2.
What I want is the date and the time in the YYYY/MM/DD hh:mm:ss format (the "pad" is to have the months, the days, the hours, the minutes and the seconds in a two-digit format, so 01, 02, ... ).
When I run the code, the date and the time are totally wrong and they even go backwards until they stabilise to a value, like in the picture attached:
The wiring is correct, I'm using a breadboard (used different places on the breadboard).
I tried to remove the battery and put it back, but nothing changes.
I tried without the battery, but nothing changes.
I installed the Time library by Michael Margolis (version 1.6.1) and used the SyncArduinoClock Processing to set a time on the DS3231and while the processing worked, once I'm back on the Arduino and my sketch, I got the weird date and time values again.
Tried both using the F() macro and not using it to see if anything changed.
Ok, it works now.
Got a multimeter and both the battery that came with the sensor and the one I used in my testing read around 3.7 V.
Got a new battery (read about 3.3 V) and at first the serial monitor was blank.
I loaded @PaulRB's sketch (reply #5) and it worked, but the time was 3 minutes behind.
Then I loaded my sketch and it also worked, although the time was still 3 minutes behind.
The sketch I posted was written to give the same results as your sketch, but, as you see, it is far shorter and simpler.
The 3.7V batteries are probably rechargeable lithium-ion and the 3.3V is probably a non-rechargeable lithium battery. Either should work fine, so I don't understand why the 3.7V batteries did not work.
Did you try the 3.7V batteries again, now that your sketch is working?
Also, please do not post screen captures of serial monitor. Instead, copy the text from serial monitor and paste that into your post between code tags.