Getting a string variable from Adafruit's RTClib

Hello,

I am using Adafruit's RTClib but one of my bits of code I need to get hold of the date/Time in the format YYYYMMDDHHMMSS as a string to write to an SD card and matching but for the love of things I can't seem to do it.

I can get the date/time in decimal format from their example in the library but how to convert the reply to a string?

If anyone here uses RTClib and can help I would be grateful.

The library is available here

No you don't :wink: If you want to write it to the SD card in that format, just write it in that order :wink: No need to make a string of it first and then write it.

file.print(now.year());
file.print(now.month());
file.print(now.day());
file.print(now.hour());
file.print(now.minute());
file.print(now.second());

Alright, that leaves you with a different problem, how to print a day/month/hour/minute/second of 4 as 04. But that's a different question :wink: