如题:
假如现在有记录时间的变量
int iYear = 2016;
int iMonth = 8 ;
int iDay = 9;
int iHour = 5;
int iMinute = 6;
int iSecond = 1;
想得到的效果是:2016-08-09 05:06:01的格式
解决方案:
CString strYear = L"";
strYear.Format(L"%d",iYear );
CString strMonth = L"";
strMonth.Format(L"%.2d",iMonth);
CString strDay = L"";
strDay.Format(L"%.2d", iDay);
CString strHour = L"";
strHour.Format(L"%.2d",iHour );
CString strMinute = L"";
strMinute .Format(L"%.2d", iMinute);
CString strSecond = L"";
strSecond.Format(L"%.2d",iSecond);
总结:
注意点也就是. 和2