From: http://www.cnblogs.com/yjm0105/archive/2009/07/16/180620.html
1. Use the ctime class
Cstring STR;
// Obtain the system time
Ctime TM;
TM = ctime: getcurrenttime ();
STR = TM. Format ("the current time is % Y % m month % d % x ");
MessageBox (STR, null, mb_ OK );
2: Get the system time and date (using getlocaltime)
Systemtime st;
Cstring strdate, strtime;
Getlocaltime (& St );
Strdate. Format ("% 4D-% 2D-% 2D", st. wyear, st. wmonth, st. wday );
Strtime. Format ("% 2D: % 2D: % 2D", st. whour, st. wminute, st. wsecond );
3. Use gettickcount
// ObtainProgramRunning time
Long T1 = gettickcount (); // gets the system Runtime (MS) before the start of the program segment)
Sleep (500 );
Long T2 = gettickcount (); // gets the system Runtime (MS) after the program segment ends)
Str. Format ("Time: % DMS", t2-t1); // The difference between front and back is the running time
Afxmessagebox (STR );
// Obtain the system running time
Long T = gettickcount ();
Cstring STR, str1;
Str1.format ("when the system is running % d", T/3600000 );
STR = str1;
T % = 3600000;
Str1.format ("% d points", T/60000 );
STR + = str1;
T % = 60000;
Str1.format ("% d seconds", T/1000 );
STR + = str1;
Afxmessagebox (STR );