Text file name saved as current date and time?
Posted on 2007-04-02
I have a program with needs to contain the system's date and time as a text file name for a flat file that the C++ program creates (ex: 20070402134525.txt)
I've already got the program pulling the system date and time (see below.) I just need to know how I can get that information in to the file name.
struct tm *loctime;
// Get the current time.
curtime = time (NULL);
// Convert it to local time representation.
loctime = localtime (&curtime);
//Date and time format
strftime (buffer, SIZE, "%Y%m%d%H%M%S", loctime);