//
格式为:2008-01-01
CTime StrToTime(CString strTime)
{
int nYear,nMonth,nDay;
sscanf(strTime,"%d-%d-%d",&nYear,&nMonth,&nDay);
CTime Time(nYear,nMonth,nDay,0,0,0);
return Time;
}

CString TimeToStr(CDateTimeCtrl
&
DateTime)
{
CTime Time;
DateTime.GetTime(Time);
return Time.Format("%Y-%m-%d");
}
PS:
SYSTEMTIME Time;
GetLocalTime(&Time);
//2008-01-01 12:12:12 -> 080101121212
m_BillNo.Format("%02d%02d%02d%02d%02d",Time.wYear-2000,Time.wMonth,Time.wDay,Time.wHour,Time.wMinute);
本文介绍了如何在C++中实现CDateTimeCtrl与CString之间的相互转换。提供了将CString转换为CTime以及将CDateTimeCtrl对象转换为CString的具体实现代码。

2978

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



