The following format codes / directives are listed both from the 1989 C standard (work on all platforms that implement the standard) and additional (according to ISO 8601).
ISO 8601 codes using
strftime () may not be available on some platforms. ISO 8601 year and week directives are not compatible with those of 1989 C (cf.
% G and
% Y ).
Python uses the
strftime () system function, so the full list of supported directives may vary for different platforms. This page lists the main ones. For a complete list, see the documentation for
strftime ( debian ).
|%%|| Used to get the ||%|
|Date and time|
|%c||Date and time (by current locale)|| en_US: ||1|
|% x||Date (by current locale)|| en_US: ||1|
|%X||Time (according to the current locale)|| en_US: ||1|
|Day b >|
|% d||Month number (leading zero)||01, 02, 31||9|
|% j||Year number (leading zero)||001, 002, 266||9|
|% U||Year number, two digits. First day of week: Sunday (previous days of the year are on week 0)||00, 01, 53||7, 9|
|% W||Number in the year, two digits. First day of week: Monday (previous days of the year fall on week 0)||00, 01, 53||7, 9|
|% V||+ py3.6 ISO 8601. Year number, two digits. First day of the week: Monday; week 01 contains January 4th||01, 02, 53||8, 9|
|% a||Short name of the day (according to the current locale)||en_US: Sun, Mon; ru_RU: Sun, Mon||1|
|% А||Full name of the day (according to the current locale)||en_US: Thursday; ru_RU: Thursday||1|
|% w||Day number, one digit (0 - Sunday, 6 - Saturday)||0, 1, 6|
|% u||+ py3.6 ISO 8601. Day number, one digit (1 - Monday)||1, 2, 7|
|% b||Short name (by current locale)||en_US: Jan, Feb; ru_RU: Jan, Feb||1|
|% B||Full name (according to the current locale)||en_US: January; ru_RU: January||1|
|% m||Number, two digits (leading zero)||01 , 02, 12||9|
|% y||Number, two digits (leading zero)||01, 02, 99||9|
|%Y||Number, four digits (leading zero)||0001, 0002, 9999||2|
|% G|| + py3.6 ISO 8601. Number, four digits. The century includes most of the week (see ||0001, 2017, 9999||8|
|% H||Hour number, 24 hours, two digits (leading zero)||01, 02, 23||9|
|% M||Minute, two digits (leading zero)||00, 01, 59||9|
|% S||Second number, two digits (leading zero)||00, 01, 59||4, 9|
|% f||+ py2.6 Microsecond number, six digits (leading zero)||000000, 000001, 999999||5|
|% z|| Offset from UTC in the format ||6|
|% Z||Timezone name||& lt; empty & gt ;, UTC, EST, CST|
|% I||Hour number, 12 o'clock, two digits (leading zero) td >||01, 02, 12||9|
|% p||AM / PM half day indicator (by current locale )||e n_US: AM; ru_RU: ''||1, 3|
strptime ()can parse years in the range [1, 9999] (since + py3.3; in + py3.2 - [1000, 9999]; formerly [1900, 9999]), however years & lt; 1000 must have four digits with leading zeros.
strptime (), the
% pdirective affects the output of the hour field if
% Iwas used to parse the hour.
datetimemodule does not support leaping seconds.
strptime (), the
% fdirective supports one to six digits and zero padding to the right.
% fis an extension of the C formatting character set implemented for
datetimeobjects and therefore always available.
strptime (), the directives
% Ware used in calculations only when specifying the day of the week and calendar year (
strptime (), the
% Vdirective, like
% W, is used in calculations only when specifying the day of the week and ISO year (
strptime (), for directives
% Vleading zeros are optional. For the
% yformat, a leading zero is required .
Executing Data Quality Projects: Ten Steps to Quality Data and Trusted Information (TM), 2nd Edition. Execute Data Quality Projects, Second Edition presents a structured yet flexible approach to cr...
We live in an age of so-called Big Data. We hear terms like data scientist, and there is much talk about analytics and the mining of large amounts of corporate data for tidbits of business value. Ther...
Coding for Kids: Python - Learn to Code with 50 Awesome Games and Activities. Learning to code isn't as difficult as it sounds, you just have to get started! Coding for Kids: Python gets kids start...
ig Data applications are growing very rapidly around the globe. This new approach to decision making takes into account data gathered from multiple sources. Here my goal is to show how these diverse s...