CTime t=CTime::GetCurrentTime(); //得到當前系統時間
int year = time.GetYear(); //返回年
int mouth = time.GetMouth(); //返回月份
int date = time.GetDay(); // 返回日數
int hour = time.GetHour(); // 返回小時數(-23至23之間)
int min = time.GetMinute(); // 返回分鐘數(-59至59之間)
int sec = time.GetSecond(); // 返回秒數(-59至59之間)
//轉化爲字符串
CString strTime;
strTime.Format("%d%d%d%d%d%d",t.GetYear(),t.GetMonth(),t.GetDay(),t.GetHour(),t.GetMinute(),t.GetSecond());