Skip to content

Instantly share code, notes, and snippets.

@msbanik
Last active December 25, 2015 17:59
Show Gist options
  • Save msbanik/7016796 to your computer and use it in GitHub Desktop.
Save msbanik/7016796 to your computer and use it in GitHub Desktop.
date format python
+-------------+----------------------------------+--------------------------+---------+
| Directive | Meaning | Example | Notes |
+=============+==================================+==========================+=========+
| %a | Weekday as locale's abbreviated | Sun, Mon, ..., Sat | (1) |
| | name. | (en_US);So, Mo, ..., Sa | |
| | | (de_DE) | |
+-------------+----------------------------------+--------------------------+---------+
| %A | Weekday as locale's full name. | Sunday, Monday, ..., | (1) |
| | | Saturday | |
| | | (en_US);Sonntag, Montag, | |
| | | ..., Samstag (de_DE) | |
+-------------+----------------------------------+--------------------------+---------+
| %w | Weekday as a decimal number, | 0, 1, ..., 6 | |
| | where 0 is Sunday and 6 is | | |
| | Saturday. | | |
+-------------+----------------------------------+--------------------------+---------+
| %d | Day of the month as a zero- | 01, 02, ..., 31 | |
| | padded decimal number. | | |
+-------------+----------------------------------+--------------------------+---------+
| %b | Month as locale's abbreviated | Jan, Feb, ..., Dec | (1) |
| | name. | (en_US);Jan, Feb, ..., | |
| | | Dez (de_DE) | |
+-------------+----------------------------------+--------------------------+---------+
| %B | Month as locale's full name. | January, February, ..., | (1) |
| | | December (en_US);Januar, | |
| | | Februar, ..., Dezember | |
| | | (de_DE) | |
+-------------+----------------------------------+--------------------------+---------+
| %m | Month as a zero-padded decimal | 01, 02, ..., 12 | |
| | number. | | |
+-------------+----------------------------------+--------------------------+---------+
| %y | Year without century as a zero- | 00, 01, ..., 99 | |
| | padded decimal number. | | |
+-------------+----------------------------------+--------------------------+---------+
| %Y | Year with century as a decimal | 1970, 1988, 2001, 2013 | |
| | number. | | |
+-------------+----------------------------------+--------------------------+---------+
| %H | Hour (24-hour clock) as a zero- | 00, 01, ..., 23 | |
| | padded decimal number. | | |
+-------------+----------------------------------+--------------------------+---------+
| %I | Hour (12-hour clock) as a zero- | 01, 02, ..., 12 | |
| | padded decimal number. | | |
+-------------+----------------------------------+--------------------------+---------+
| %p | Locale's equivalent of either AM | AM, PM (en_US);am, pm | (1), |
| | or PM. | (de_DE) | (2) |
+-------------+----------------------------------+--------------------------+---------+
| %M | Minute as a zero-padded decimal | 00, 01, ..., 59 | |
| | number. | | |
+-------------+----------------------------------+--------------------------+---------+
| %S | Second as a zero-padded decimal | 00, 01, ..., 59 | (3) |
| | number. | | |
+-------------+----------------------------------+--------------------------+---------+
| %f | Microsecond as a decimal number, | 000000, 000001, ..., | (4) |
| | zero-padded on the left. | 999999 | |
+-------------+----------------------------------+--------------------------+---------+
| %z | UTC offset in the form +HHMM or | (empty), +0000, -0400, | (5) |
| | -HHMM (empty string if the the | +1030 | |
| | object is naive). | | |
+-------------+----------------------------------+--------------------------+---------+
| %Z | Time zone name (empty string if | (empty), UTC, EST, CST | |
| | the object is naive). | | |
+-------------+----------------------------------+--------------------------+---------+
| %j | Day of the year as a zero-padded | 001, 002, ..., 366 | |
| | decimal number. | | |
+-------------+----------------------------------+--------------------------+---------+
| %U | Week number of the year (Sunday | 00, 01, ..., 53 | (6) |
| | 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 | Week number of the year (Monday | 00, 01, ..., 53 | (6) |
| | 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. | | |
+-------------+----------------------------------+--------------------------+---------+
| %c | Locale's appropriate date and | Tue Aug 16 21:30:00 1988 | (1) |
| | time representation. | (en_US);Di 16 Aug | |
| | | 21:30:00 1988 (de_DE) | |
+-------------+----------------------------------+--------------------------+---------+
| %x | Locale's appropriate date | 08/16/88 | (1) |
| | representation. | (None);08/16/1988 | |
| | | (en_US);16.08.1988 | |
| | | (de_DE) | |
+-------------+----------------------------------+--------------------------+---------+
| %X | Locale's appropriate time | 21:30:00 | (1) |
| | representation. | (en_US);21:30:00 (de_DE) | |
+-------------+----------------------------------+--------------------------+---------+
| %% | A literal '%' character. | % | |
+-------------+----------------------------------+--------------------------+---------+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment