#include <atltime.h>
CTime tm;
tm=CTime::GetCurrentTime();
CString str;
str=tm.Format(_T("%Y%-m%-d %H-%M-%S"));
The formatting codes for strftime are listed below:
%I
Hour in 12-hour format (01 – 12)
Day of year as decimal number (001 – 366)
Month as decimal number (01 – 12)
Minute as decimal number (00 – 59)
Current locale's A.M./P.M. indicator for 12-hour clock
Second as decimal number (00 – 59)
Week of year as decimal number, with Sunday as first day of week (00 – 53)
Weekday as decimal number (0 – 6; Sunday is 0)
Week of year as decimal number, with Monday as first day of week (00 – 53)
Date representation for current locale
Time representation for current locale
Year without century, as decimal number (00 – 99)
Year with century, as decimal number
Either the time-zone name or time zone abbreviation, depending on registry settings; no characters if time zone is unknown
Percent sign