Can the Labeled Value widget Display Leading Zeros from RTC time data?

Hi, Im using the RTC widget to display the time on Labeled Value widgets on my project. The widgets work well, time is displayed correctly, however . . . when any of H, M or S are single digits, only the single digit is displayed:

eg 8:48:8 or 21:3:56

Is it possible to display the leading zero in the Labeled Display widget for the single digits?

eg. 08:48:08 or 21:03:56

I’ve found answers for formatiing for Serial Print (RTC code to show value on widget), and I’ve tried expanding similar formatting that works for floats in the Labeled Value widget (eg /pin.##/) - I tried /pin.##.##.##/ but this didnt work.

Suggestions greatly appreciated.

Your answer was right there in the link you provided… works just fine for a labled display

This is what I use:

char currentTime[9];
char currentDate[11];

void timedateDisplay() {
sprintf(currentTime, "%02d:%02d:%02d", hour(), minute(), second());
sprintf(currentDate, "%02d/%02d/%04d", month(), day(), year());
Blynk.virtualWrite(V0, currentTime);  // Send time to Display Widget
Blynk.virtualWrite(V1, currentDate);  // Send date to Display Widget


Of course you still need any RTC stuff :wink:

1 Like

Great, thnx for the quick response! I’m not familiar with sprintf(), with the brief reding I’ve done I ASSUMED (first mistake . . .) that it was formatting for serial print only. Will try this out as soon as I get home later today,


Well, probably not it’s official name, but I call it serialprintformat() :stuck_out_tongue_winking_eye: and once the data is formatted, it can be used for a serial print or equivalent, in our case a display widget :wink:

Maybe it was as stringprintformat…

That makes more sense :+1: