vc++ DATE类型 转 CString
在vc++中DATE类型如何转为CString???在vs2008中DATE类型如何转为CString???...
在vc++中
DATE类型 如何转为 CString ???
在vs2008中
DATE类型 如何转为 CString ??? 展开
DATE类型 如何转为 CString ???
在vs2008中
DATE类型 如何转为 CString ??? 展开
4个回答
展开全部
CTime==>CString
CTime time;
time.GetCurrentTime();
CString str;
str.Format("%s",time.Format("%y:%m:%d %H-%M-%S")
1
CString str;
CTime t = CTime::GetCurrentTime();
str.Format("%d-%d-%d",t.GetYear(),t.GetMonth(),t.GetDay());
2
CString strTime;
CTime tTime = CTime::GetCurrentTime();
strTime = tTime.Format("%Y-%m-%d %H:%M:%S");
CString ==>CTime
strCString="2003-10-27 6:24:37"; //CString--->COleDateTime
COleVariant vtime(strCString);
vtime.ChangeType(VT_DATE);
COleDateTime time4=vtime;
COleDateTime time1(1977,4,16,2,2,2); //COleDataTime--->CTime
SYSTEMTIME systime;
VariantTimeToSystemTime(time1, &systime);
CTime tm(systime);
time_t time2=tm.GetTime(); //CTime--->time_t
COleDateTime time3(time2); //time_t--->COleDateTime
时间差
COleDateTime strFirst,strEnd;
strFirst = COleDateTime(strFirst.GetYear(),strFirst.GetMonth(),strFirst.GetDay(),0,0,0);
strEnd = COleDateTime(tmCurrent.GetYear(),tmCurrent.GetMonth(),tmCurrent.GetDay(),23,59,59);
tspan= strEnd - strFirst;
CTime time;
time.GetCurrentTime();
CString str;
str.Format("%s",time.Format("%y:%m:%d %H-%M-%S")
1
CString str;
CTime t = CTime::GetCurrentTime();
str.Format("%d-%d-%d",t.GetYear(),t.GetMonth(),t.GetDay());
2
CString strTime;
CTime tTime = CTime::GetCurrentTime();
strTime = tTime.Format("%Y-%m-%d %H:%M:%S");
CString ==>CTime
strCString="2003-10-27 6:24:37"; //CString--->COleDateTime
COleVariant vtime(strCString);
vtime.ChangeType(VT_DATE);
COleDateTime time4=vtime;
COleDateTime time1(1977,4,16,2,2,2); //COleDataTime--->CTime
SYSTEMTIME systime;
VariantTimeToSystemTime(time1, &systime);
CTime tm(systime);
time_t time2=tm.GetTime(); //CTime--->time_t
COleDateTime time3(time2); //time_t--->COleDateTime
时间差
COleDateTime strFirst,strEnd;
strFirst = COleDateTime(strFirst.GetYear(),strFirst.GetMonth(),strFirst.GetDay(),0,0,0);
strEnd = COleDateTime(tmCurrent.GetYear(),tmCurrent.GetMonth(),tmCurrent.GetDay(),23,59,59);
tspan= strEnd - strFirst;
展开全部
转换代码如下:
CString strTime;
CTime time = CTime::GetCurrentTime(); //获取系统当前时间;
strTime.Format("%d年%d月%d日%d时%d分%d秒",
time.GetYear(),time.GetMonth(),time.GetDay(), time.GetHour(),time.GetMinute(),time.GetSecond());
CString strTime;
CTime time = CTime::GetCurrentTime(); //获取系统当前时间;
strTime.Format("%d年%d月%d日%d时%d分%d秒",
time.GetYear(),time.GetMonth(),time.GetDay(), time.GetHour(),time.GetMinute(),time.GetSecond());
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
CString DateToString(CTime &tm)
{
CString str_time;
str_time.Format("%d-%d-%d",tm.GetYear(),tm.GetMonth(),tm.GetDay());
return str_time;
}
{
CString str_time;
str_time.Format("%d-%d-%d",tm.GetYear(),tm.GetMonth(),tm.GetDay());
return str_time;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询