Using char strings and sprintf - problem with Time.format()

Time.format() returns a String object but sprintf() only knows pure C strings (aka char arrays).
So you need to cast the String object to (const char*) (or use someString.c_str() instead).

Like this

    sprintf(timeonlyInChar, "%s", (const char*)Time.format("%I:%M%p"));   // This should work

(also no need to state Time.now() in Time.format() - without that parameter now is assumed)

You can use this image for preformatted text (including code blocks) or use ```cpp (as separate line without blanks) before the code block and the same without the "cpp" part after it.

For more tips and tricks you can look here