VC++ CTime Format 详解

参考链接:

VC++中CTime类Format参数详解

CTime/COleDateTime::Format方法的使用 

http://stat.ethz.ch/R-manual/R-devel/library/base/html/strptime.html

http://www.geezer.org/sw/mvform/doc/strftime.txt

 

CTime::Format主要用来格式化日期和时间。

举例:

    CTime ctNow=CTime::GetCurrentTime();



    CString strTime1 = ctNow.Format(_T("%Y年%m月%d日"));              // 2014年05月27日

    CString strTime2 = ctNow.Format(_T("%Y-%m-%d %H:%M:%S"));        // 2014-05-27 14:24:45

    CString strTime3 = ctNow.Format(_T("%Y-%#m-%#d %H:%M:%S"));      // 2014-5-27 14:24:45

    CString strTime4 = ctNow.Format(_T("%c"));                       // 05/27/14 14:24:45

 

 

格式化的参数详细列举如下:

Formats
Description
Memo/Example
%a
abbreviated weekday name 
 
星期的缩写
%A
full weekday name
 
完整的星期名
%b
abbreviated month name
 
月份的缩写
%B
full month name
 
完整的月份名
%c
locale's date and time representation
 
当前区域(设置)的日期和时间, 
如,05/27/14 13:42:43
%d
the day of the month as a decimal number (01-31)
 
如,27
%H
the hour (24-hour clock) as a decimal number(00-23)
 
24小时制的小时(00-23)
%I
the hour (12-hour clock) as a decimal number(01-12)
 
12小时制的小时(00-12)
%j
the day of the year as a decimal number (001-366).
 
一年的第几天
如,147
%m
the month as a decimal number (01-12).
 
月份(00-12)
如,05
%M
the minute as a decimal number (00-59).
 
分钟(00-59)
%p
locale's equivalent of ``AM'' (ante meridiem) or ``PM'' (post meridiem) as appropriate
 
PM 或者 AM
%S
the second as a decimal number (00-60)
 
秒钟(00-59)
%U
the week number of the year (the first Sunday as the first day of week 1) as a decimal number (00-53).
 
一年的第几周(周日是第一周的第一天)
%w
the weekday (Sunday as the first day of the week) as a decimal number (0-6).
 
工作日(0-6,周日是一周的第一天)
%W
 
the week number of the year (the first Monday as the first day of week 1) as a decimal number (00-53).
 
一年的第几周(周一是第一周的第一天)
%x
 
locale's date representation
 
当地区域的日期
如,05/27/2014
%X
 
locale's time representation
 
当地区域的时间
如,13:54:12
%y
 
the year without century as a decimal number (00-99).
 
年(00-99)
如, 14
%Y
 
the year with century as a decimal number.
 
如,2014
%Z
 
the time zone name
 
时区名称
如,China Standard Time

 

月份的全称和缩写:                                                                            星期的全称和缩写:

Full Month Name

Abbreviated Month Name

January

Jan

February

Feb

March

Mar

April

Apr

May

May

June

Jun

July

Jul

August

Aug

September

Sep

October

Oct

November

Nov

December

Dec

 

Full Weekday Name

Abbreviated Weekday Name

Sunday

Sun

Monday

Mon

Tuesday

Tue

Wednesday

Wed

Thursday

Thu

Friday

Fri

Saturday

Sat

             

 

 

 

 

 

你可能感兴趣的:(format)