1.
CTime time = CTime::GetCurrentTime();
int year = time.GetYear(); //返回年
int month = time.GetMonth(); //返回月份
int date = time.GetDay(); // 返回日数
int hour = time.GetHour(); // 返回小时数(-23至23之间)
int min = time.GetMinute(); // 返回分钟数(-59至59之间)
int sec = time.GetSecond(); // 返回秒数(-59至59之间)
CString str;
str.Format("%d-%d-%d %d:%d:%d",year, month, date, hour, min, sec);
2.
CTime time = CTime::GetCurrentTime();
CString str = time.Format("%Y-%m-%d %H:%M:%S");