Python Cheatsheet: Strftime
Python Cheatsheet: Strftime
https://strftime.org 1/3
9/10/22, 3:35 PM Python strftime reference cheatsheet
%z +0000 UTC offset in the form ±HHMM[SS[.ffffff]] (empty string if the object is
naive).
%U 36 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.
%W 35 Week number of the year (Monday as the first day of the week) as a
decimal number. All days in a new year preceding the first Monday are
considered to be in week 0.
Platform-specific directives
The full set of format codes supported varies across platforms, because Python calls the platform C
library's strftime() function, and platform variations are common. To see the full set of format codes
supported on your platform, consult the strftime(3) documentation.
The Python docs contain all the format codes that the C standard (1989 version) requires, and these
work on all platforms with a standard C implementation. Note that the 1999 version of the C
standard added additional format codes. These include codes for non-zero-padded numbers, that
can be obtained by appending a dash (-) (UNIX) or hash (#) (Windows) after the percent (%) sign.
Source
This cheatsheet was built from the Python standard library strftime documentation. See
github.com/mccutchen/strftime.org for the build source code.
https://strftime.org 2/3
9/10/22, 3:35 PM Python strftime reference cheatsheet
See also
You might also like PyFormat.info or the interactive strfti.me.
https://strftime.org 3/3