Programming Tips - How can I quickly make a nice timestamp string?

Date: 2010jan19 Language: C/C++ Level: beginner OS: Linux Q. How can I quickly make a nice timestamp string? A. Here's a function that does that:
#include <time.h> // eg "Wed Jun 30 21:49:08 1993" static void timeStamp(char *szTime, const size_t size) { time_t now; szTime[0] = '\0'; if (size < 25) return; now = time(NULL); ctime_r(&now, szTime); szTime[24] = '\0'; // Zap the newline } void exampleUse() { char szTime[100]; timeStamp(szTime, sizeof(szTime)); printf("It is now %s\n", szTime); }