首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

怎么取系统当前时间

2012-03-04 
如何取系统当前时间?如何取系统当前时间?[解决办法]SYSTEMTIMEcurTimeGetLocalTime(&curTime)[解决办法]

如何取系统当前时间?
如何取系统当前时间?

[解决办法]
SYSTEMTIME curTime;
GetLocalTime( &curTime );
[解决办法]

下面代码是用 MFC 的 COleDateTime 类获取时间:

C/C++ code
// example for COleDateTime::GetCurrentTimeCOleDateTime dateTest;   // dateTest value = midnight 30 December 1899dateTest = COleDateTime::GetCurrentTime();   // dateTest value = current date and time
[解决办法]
1,
COleDateTime dtCurrent;
dtCurrent = COleDateTime::GetCurrentTime();
CString strData = dtCurrent.Format("%Y年%m月%d %H:%M:%S 第%U周 星期%w");

2,
SYSTEMTIME time;
CString strData;
GetLocalTime(&time);
strData.Format("%d-%d-%d,%d:%d:%d",time.wYear,time.wMonth,time.wDay,time.wHour,time.wMinute,time.wSecond);

3,
CTime time = CTime::GetCurrentTime();
CString sCurDate=time.Format("%Y年%m月%d %H:%M:%S 第%U周 星期%w");

热点排行