|
发表于 2020-9-3 18:15:01
|
显示全部楼层
我写的一个获得当前机器时间的函数,其中可以更具入参的nType不同,输出不同格式的时间。
CString GetCurTime(TIME_TYPE nType)
{
// CString strFileName = "";
CString strTime = "";
CTime tmCur = CTime::GetCurrentTime();
switch(nType)
{
case DATE_LONG:
strTime = tmCur.Format("%Y-%m-%d %H:%M:%S");
break;
case DAY_NORMAL:
strTime = tmCur.Format("%Y%m%d");
break;
case TIME_NORMAL:
strTime = tmCur.Format("%H%M%S");
break;
case DATE_NORMAL:
strTime = tmCur.Format("%Y%m%d%H%M%S");
break;
case DAY_SHORT:
strTime = tmCur.Format("%m%d");
break;
case DAY_LONG:
strTime = tmCur.Format("%Y-%m-%d");
break;
case TIME_LONG:
strTime = tmCur.Format("%H:%M:%S");
break;
case MONTH_NORMAL:
strTime = tmCur.Format("%Y%m");
break;
case MONTH_LONG:
strTime = tmCur.Format("%Y年%m");
break;
case TIME_NORAML:
strTime = tmCur.Format("%M%S");
break;
}
return strTime;
} |
|