How about
void tm2str(struct tm *timeInfo, char *buf) Get rid of the return.
And in your main you call where you declared buf[20]:
tm2str(timeinfo, buf);