16,551
社区成员
发帖
与我相关
我的任务
分享
CTime currenttime = CTime::GetCurrentTime();
CString strCurrentTime = currenttime.Format("%Y-%m-%d %H:%M:%S");
这个函数可以把 "20091013"这样的字符串 转化为CTime类型
在函数中添加 上时间就可以
CTime StrToCTime(CString m_strTime)
{
if (m_strTime.GetLength()!=8)
{
return 0;
}
int nYear=atoi(m_strTime.Mid(0,4));
int nMonth=atoi(m_strTime.Mid(4,2));
int nDay=atoi(m_strTime.Mid(6,2));
CTime myTime(nYear,nMonth,nDay,23,0,0);
return myTime;
}