|
I wrote a function to get the current machine time, which can have different input parameters and output the time in different formats.
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("%Yyear%m");
break;
case TIME_NORAML:
strTime = tmCur.Format("%M%S");
break;
}
return strTime;
} |
|