Hi,
I’m trying to put a formatted timestamp into a string to send to Blynk. The Time.format() command works fine when I use it directly in a serial print, but not if I try to use sprintf to put it into a char string first…I get 3 strange characters, that vary with the timestamp
eg (sorry I’m not sure how to format this as a code window in the post)
char timeonlyInChar[15];
void setup() {
Serial.begin(9600);
Serial.println(Time.format(Time.now(),"%I:%M%p")); // This will print OK
sprintf(timeonlyInChar, "%s", Time.format(Time.now(),"%I:%M%p")); // This wont
Serial.print(timeonlyInChar);
}
void loop() {
}
The output is something like this…
05:26AM
PW╗
What am I missing?
thanks
Pete