| Format Code | Description | Example | Use in strptime/strftime |
|---|---|---|---|
| %Y | Year with century (4 digits) | 2024 | strptime/strftime |
| %y | Year without century (2 digits) | 24 | strptime/strftime |
| %m | Month as a zero-padded decimal number | 07 (for July) | strptime/strftime |
| %B | Full month name | July | strptime/strftime |
| %b | Abbreviated month name | Jul | strptime/strftime |
| %d | Day of the month as a zero-padded number | 18 | strptime/strftime |
| %A | Full weekday name | Wednesday | strptime/strftime |
| %a | Abbreviated weekday name | Wed | strptime/strftime |
| %H | Hour (24-hour clock) as a zero-padded number | 14 (2 PM) | strptime/strftime |
| %I | Hour (12-hour clock) as a zero-padded number | 02 (2 PM) | strptime/strftime |
| %M | Minute as a zero-padded decimal number | 05 | strptime/strftime |
| %S | Second as a zero-padded decimal number | 09 | strptime/strftime |
| %p | AM or PM designation | AM | strptime/strftime |
| %Z | Time zone name | EST | strptime/strftime |
| %z | UTC offset in the form ±HHMM | +0200 | strptime/strftime |
| %j | Day of the year as a zero-padded number | 199 | strptime/strftime |
| %U | Week number of the year (Sunday as the first day) | 29 | strptime/strftime |
| %W | Week number of the year (Monday as the first day) | 28 | strptime/strftime |
| %c | Locale’s date and time representation | Wed Jul 18 10:30:00 2024 | strftime |
| %x | Locale’s date representation | 07/18/2024 | strftime |
| %X | Locale’s time representation | 10:30:00 | strftime |
| Date-Time Segment | Format Code | Example | Description |
|---|---|---|---|
| Full Year | %Y |
2024 |
4-digit year |
| Short Year | %y |
24 |
2-digit year |
| Month (Full) | %B |
July |
Full month name |
| Month (Abbr) | %b |
Jul |
Abbreviated month name |
| Month (Number) | %m |
07 |
2-digit month number |
| Day | %d |
18 |
Day of the month (01 to 31) |
| Weekday (Full) | %A |
Wednesday |
Full name of the weekday |
| Weekday (Abbr) | %a |
Wed |
Abbreviated weekday name |
| Hour (24-hour) | %H |
14 |
24-hour clock hour (00 to 23) |
| Hour (12-hour) | %I |
02 |
12-hour clock hour (01 to 12) |
| Minute | %M |
05 |
Minute (00 to 59) |
| Second | %S |
09 |
Second (00 to 59) |
| AM/PM | %p |
AM |
AM or PM indicator |
| Time Zone | %Z |
EST |
Time zone abbreviation |
| UTC Offset | %z |
+0200 |
UTC offset (±HHMM) |
| Day of Year | %j |
199 |
Day of the year (001 to 366) |
| Week Number (Sun) | %U |
29 |
Week number of the year (weeks start on Sunday) |
| Week Number (Mon) | %W |
28 |
Week number of the year (weeks start on Monday) |
| Full Date-Time | %c |
Wed Jul 18 10:30:00 2024 |
Full date and time representation in locale format |
| Date (Locale) | %x |
07/18/2024 |
Date in locale-specific format |
| Time (Locale) | %X |
10:30:00 |
Time in locale-specific format |