alex_bn_lee

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

[929] datetime format (strftime() and strptime() Format Codes)

ref: strftime() and strptime() Format Codes


The following is a list of all the format codes that the 1989 C standard requires, and these work on all platforms with a standard C implementation.

Type

Directive

Meaning

Example

Notes

Weekday

%a

Weekday as locale's abbreviated name.

Sun, Mon, Tue, Wed, Thu, Fri, Sat

(1)

%A

Weekday as locale's full name.

Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday

(1)

%w

Weekday as a decimal number, where 0 is Sunday and 6 is Saturday.

0, 1, 2, 3, 4, 5, 6

 

Day

%d

Day of the month as a zero-padded decimal number.

01, 02, 03, 04, 05,..., 10, 11,12, ...,29, 30, 31

(9)

Month

%b

Month as locale's abbreviated name.

Jan, Feb, …, Jul, Aug, ..., Nov, Dec

(1)

%B

Month as locale's full name.

January, February, …, November, December

(1)

%m

Month as a zero-padded decimal number.

01, 02, …, 07, 08, ..., 11, 12

(9)

Year

%y

Year without century as a zero-padded decimal number.

00, 01, …, 50, 51, ..., 98, 99

(9)

%Y

Year with century as a decimal number.

0001, 0002, …, 2013, 2014, …, 9998, 9999

(2)

Hour

%H

Hour (24-hour clock) as a zero-padded decimal number.

00, 01, …, 10, 11, ..., 22, 23

(9)

%I

Hour (12-hour clock) as a zero-padded decimal number.

01, 02, …, 7, 8, ..., 11, 12

(9)

%p

Locale's equivalent of either AM or PM.

AM, PM (en_US)

(1), (3)

Minute

%M

Minute as a zero-padded decimal number.

00, 01, …, 24, 25, ..., 58, 59

(9)

Second

%S

Second as a zero-padded decimal number.

00, 01, …, 24, 25, ..., 58, 59

(4), (9)

 

%f

Microsecond as a decimal number, zero-padded to 6 digits.

000000, 000001, …, 999999

(5)

 

%z

UTC offset in the form ±HHMM[SS[.ffffff]] (empty string if the object is naive).

(empty), +0000, -0400, +1030, +063415, -030712.345216

(6)

 

%Z

Time zone name (empty string if the object is naive).

(empty), UTC, GMT

(6)

 

%j

Day of the year as a zero-padded decimal number.

001, 002, …, 366

(9)

 

%U

Week number of the year (Sunday as the first day of the week) as a zero-padded decimal number. All days in a new year preceding the first Sunday are considered to be in week 0.

00, 01, …, 53

(7), (9)

 

%W

Week number of the year (Monday as the first day of the week) as a zero-padded decimal number. All days in a new year preceding the first Monday are considered to be in week 0.

00, 01, …, 53

(7), (9)

 

%c

Locale's appropriate date and time representation.

Tue Aug 16 21:30:00 1988 (en_US);
Di 16 Aug 21:30:00 1988 (de_DE)

(1)

 

%x

Locale's appropriate date representation.

08/16/88 (None);
08/16/1988 (en_US);
16.08.1988 (de_DE)

(1)

 

%X

Locale's appropriate time representation.

21:30:00 (en_US);
21:30:00 (de_DE)

(1)


Examples: 

posted on   McDelfino  阅读(10)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2019-11-01 【446】Deep Learning
点击右上角即可分享
微信分享提示