精确到秒
CString strTime;
CTime t = CTime::GetCurrentTime();
strTime = t.Format("%Y-%m-%d\t%H:%M:%S\t");
精确到毫秒
CString strTime;
SYSTEMTIME systime;
GetSystemTime(&systime);
strTime.Format("%d%02d%02d%02d%02d%02d%03d", systime.wYear, systime.wMonth, systime.wDay,
systime.wHour+8, systime.wMinute, systime.wSecond, systime.wMilliseconds);
strcpy(szTime, strTime.GetBuffer(strTime.GetLength()+1));
struct tm *newtime;
time_t long_time;
time( &long_time ); /* Get time as long integer. */
newtime = localtime( &long_time ); /* Convert to local time. */