vc 时间控件CDateTimeCtrl的使用

这篇博客介绍了VC++中CDateTimeCtrl的使用方法,展示了如何从字符串创建CTime对象,并设置了控件的显示格式。同时,文章详细讨论了time_t类型的时间限制,提到了在Visual C++中由于time_t可能导致的问题以及解决方案,如使用__time64_t。还列举了与time_t相关的函数,如difftime、mktime等,并解释了struct tm结构体的成员。
摘要由CSDN通过智能技术生成

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值