int nYear,nMon,nDay,nMinute,nSec;
CTime tm = CTime::GetCurrentTime();
CTime tmStart(tm.GetYear(), tm.GetMonth(), 1, 0, 0, 0);
nYear = tm.GetYear();
nMon = tm.GetMonth();
if(nMon == 12)
{
nYear = nYear+1;
nMon = 1;
}
else
{
nMon = nMon+1;
}
CTime tmNext(nYear, nMon, 1, 11, 59, 59);
CTimeSpan ts(1,0,0,0);
CTime tmEnd = tmNext-ts;
nYear = tmEnd.GetYear();
nMon = tmEnd.GetMonth();
nDay = tmEnd.GetDay();
指定月的第一天和最后一天
最新推荐文章于 2025-06-16 16:33:44 发布
本文展示了一个使用C++进行时间处理的示例代码。该示例通过获取当前时间、设置开始时间、计算下个月最后一天的时间以及计算时间间隔来演示如何操作日期与时间。这些操作对于开发中涉及日期时间的应用场景非常有用。
2002

被折叠的 条评论
为什么被折叠?



