CTime 类 的Format函数和CDateTimeCtrl类的SetFormat函数的参数形式是一样的。结果被坑的不行。现将说明如下:
CTime类的Format函数参数形式
常用参数:
%Y:表示年,(大写)
%m:表示月。(注意:是小写的m)=》一定不能用大写,否则报错!
%d:表示天。(注意:是小写的d) =》一定不能用大写,否则报错!
%H:表示小时。(大写)
%M:表示分钟。(大写)
例子:
CDateTimeCtrl m_CurrentTime;
CTime CurrentTime; //CTime对象
m_CurrentTime.GetTime(CurrentTime);
CurrentTime.Format("%Y-%m-%d %H:%M");
显示:2014-5-24 09:58
CTime的Format函数的其他参数解释:
%a
Abbreviated weekday name
%A
Full weekday name
%b
Abbreviated month name
%B
Full month name
%c
Date and