Instable RTClib?

For a while this code was stable:

#include <RTClib.h>
RTC_DS1307 rtc;
DateTime epoch;
char timeinfo[80];
epoch =;
sprintf(timeinfo,"%d-%2.2d-%2.2d %2.2d:%2.2d:%2.2d ",epoch.year(),epoch.month(),,epoch.hour(),epoch.minute(),epoch.second());

But recently it became instable, it now appears to be stable again when I do this:

epoch =;
int yy,mm,dd,hhh,mmm,sss;
yy = epoch.year();
mm = epoch.month();
dd =;
hhh = epoch.hour();
mmm = epoch.minute();
sss = epoch.second();
sprintf(timeinfo,"%d-%2.2d-%2.2d %2.2d:%2.2d:%2.2d",yy,mm,dd,hhh,mmm,sss);


Why do rtc calls suddenly return garbage that I can’t print with %d? What’s up?

But recently it became instable

Unstable how?

problem resolved, there is nothing wrong with rtclib or sprintf, the problem was somewhere else in the code.


But recently it became instable

Unstable how?

like printing garbage, but it was coming from a corrupted character string, problem is resolved