// 格式爲: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");
}
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);