User Tools

Site Tools


tech_notes:strftime

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

tech_notes:strftime [2022/08/15 13:41] (current)
James Sentman created
Line 1: Line 1:
 +=====Python strftime Cheatsheet=====
 +
 +Using python for plugins means that you may encounter format strings for the python strftime function. This will let you customize the formatting of string functions in various places. You can also visit the [[https://​docs.python.org/​3/​library/​datetime.html#​strftime-and-strptime-format-codes|official python documentation for the strftime function]].
 +
 +
 +^ Directive ^ Description ^ Example ^
 +| %a | Abbreviated weekday name | Sun, Mon, Tues...|
 +| %A | Full Weekday Name | Sunday, Monday, Tuesday...|
 +| %d | Day of the month, padded to 2 digits | 01, 02, 03...|
 +| %b | Abbreviated Month Name | Jan, Feb, Mar...|
 +| %B | Full Month Name | January, February, March...|
 +| %m | Month number padded to 2 digits | 01, 02, 03...|
 +| %y | 2 digit year without century | 22, 89, 27...|
 +| %Y | 4 digit year | 2022, 1989, 2027...|
 +| %H | 24 hour clock padded to 2 digits | 00, 01, 02...24|
 +| %I | 12 hour clock padded to 2 digits | 01, 02, 03...12|
 +| %p | Locale’s version of AM or PM | AM, PM (en_US) am, pm (de_US)|
 +| %M | Minutes padded to 2 digits | 00, 01, 02...59|
 +| %S | Seconds padded to 2 digits | 00, 01, 02...59|
 +| %f | Microseconds after the exact time padded to 6 digits | 000000, 000001...999999|
 +| %z | UTC Offset | +0000, -0400, +063415, -030712.34516 |
 +| %j | Day of the year padded to 3 digits places | 001, 002, 003... |
 +| %U | Week number of the year Sunday as the first day padded to 2 digits | 00, 01...53 |
 +| %W | Week number of the year Monday as the first day padded to 2 digits | 00, 01...53 |
 +| %c | Locale date and time format | Tue Aug 16 21:30:05 1988 |
 +| %x | Locale date format | 08/16/88, 08/16/1988. 16.08.1988... |
 +| %X | Locale time format | 21:30:05 |
 +| %% | inserts a percent character without formatting | % |
 +
 +
 +%I:%M:%S%P = 06:15:00PM
 +
 +%a, %b %m = Sun, Jan 5
 +
 +%A, %B %m = Sunday, January 5
  
tech_notes/strftime.txt · Last modified: 2022/08/15 13:41 by James Sentman