strDataSource = L"2006-01-12 17:44:01";
CTime MakeDate(std::wstring strDataSource)
{
if(strDataSource.length() < 10)
return CTime();
int nYear = _wtoi(strDataSource.substr(0, 4).c_str());
int nMonth = _wtoi(strDataSource.substr(5, 2).c_str());
int nDay = _wtoi(strDataSource.substr(8, 2).c_str());
if(nYear < 1900 ||
nMonth < 1 ||
nMonth > 12 ||
nDay < 1 ||
nDay > 31)
return CTime();
return CTime(nYear, nMonth, nDay, 0, 0, 0);
}
CTime t( 1999, 3, 19, 22, 15, 0 ); // 10:15PM March 19, 1999
CTime tm;
tm=CTime::GetCurrentTime();
m_time.SetTime(&tm);
m_time.SetFormat("yyyy-MM-dd HH:mm:ss");
((CDateTimeCtrl*)GetDlgItem(ID_CTRL))->SetTime(&M
vc 时间控件CDateTimeCtrl的使用
最新推荐文章于 2024-09-02 15:24:33 发布
这篇博客介绍了VC++中CDateTimeCtrl的使用方法,展示了如何从字符串创建CTime对象,并设置了控件的显示格式。同时,文章详细讨论了time_t类型的时间限制,提到了在Visual C++中由于time_t可能导致的问题以及解决方案,如使用__time64_t。还列举了与time_t相关的函数,如difftime、mktime等,并解释了struct tm结构体的成员。
摘要由CSDN通过智能技术生成