Obtaining the Current Time and Date in a C++ Program
The function time() returns a pointer to a long integer containing the number of seconds since midnight, January 1, 1970.
The function ctime() will convert that number to a string containing the current date and time.
Example:
// check the date and time
#include <time.h>
#include <iostream.h>
main()
{
long tyme, *t;
t = &tyme;
time(t);
cout << (char*) ctime(t) << endl;
}
The program will produce output similar to the following:
Wed Sep 12 14:12:57 2001