CString str;
CTime t = CTime::GetCurrentTime();
str.Format("%d-%d-%d",t.GetYear(),t.GetMonth(),t.GetDay());

CString strTime;
CTime tTime = CTime::GetCurrentTime();
strTime = tTime.Format("%Y-%m-%d %H:%M:%S");
本文介绍了一种使用CTime类从C++程序中获取当前日期和时间的方法。通过实例展示了如何格式化日期为年-月-日的形式,并进一步获取包含小时、分钟和秒的完整时间格式。
CString str;
CTime t = CTime::GetCurrentTime();
str.Format("%d-%d-%d",t.GetYear(),t.GetMonth(),t.GetDay());

CString strTime;
CTime tTime = CTime::GetCurrentTime();
strTime = tTime.Format("%Y-%m-%d %H:%M:%S");

被折叠的 条评论
为什么被折叠?