In [1]:
from datetime import datetime
now = datetime.now()
print(now)
2019-08-28 14:25:35.711200

Code - %a : Weekday as locale’s abbreviated name.
Example:
Sun, Mon, …, Sat (en_US);
So, Mo, …, Sa (de_DE)

In [2]:
day = now.strftime("%a") 
print("Weekday as locale’s abbreviated name:", day)
Weekday as locale’s abbreviated name: Wed

Code - %A : Weekday as locale’s full name
Example:
Sunday, Monday, …, Saturday (en_US);
Sonntag, Montag, …, Samstag (de_DE)

In [3]:
day = now.strftime("%A") 
print("Weekday as locale’s full name:", day)
Weekday as locale’s full name: Wednesday

Code - %w: Weekday as a decimal number, where 0 is Sunday and 6 is Saturday.
Example:
0, 1, …, 6

In [4]:
day = now.strftime("%w") 
print("Weekday as a decimal number:", day)
Weekday as a decimal number: 3

Code - %d: Day of the month as a zero-padded decimal number.
Example:
01, 02, …, 31

In [5]:
day = now.strftime("%d") 
print("Day of the month as a zero-padded decimal number:", day)
Day of the month as a zero-padded decimal number: 28

Code - %b: Month as locale’s abbreviated name.
Example:
Jan, Feb, …, Dec (en_US);
Jan, Feb, …, Dez (de_DE)

In [6]:
day = now.strftime("%b") 
print("Month as locale's abbreviated name:", day)
Month as locale's abbreviated name: Aug

Code - %B: Month as locale’s full name.
Example:
January, February, …, December (en_US);
Januar, Februar, …, Dezember (de_DE)

In [7]:
day = now.strftime("%B") 
print("Month as locale's full Name:", day)
Month as locale's full Name: August

Code - %m: Month as a zero-padded decimal number.
Example:
01, 02, …, 12

In [8]:
day = now.strftime("%m") 
print("Month as a zero-padded decimal number:", day)
Month as a zero-padded decimal number: 08

Code - %y: Year without century as a zero-padded decimal number.
Example:
00, 01, …, 99

In [9]:
day = now.strftime("%y") 
print("Year without century as a zero-padded decimal number:", day)
Year without century as a zero-padded decimal number: 19

Code - %Y: Year with century as a decimal number.
Example:
0001, 0002, …, 2013, 2014, …, 9998, 9999

In [10]:
day = now.strftime("%Y") 
print("Year with century as a decimal number:", day)
Year with century as a decimal number: 2019

Code - %H: Hour (24-hour clock) as a zero-padded decimal number.
Example:
00, 01, …, 23

In [11]:
day = now.strftime("%H") 
print("Hour as a zero-padded decimal number:", day)
Hour as a zero-padded decimal number: 14

Code - %I: Hour (12-hour clock) as a zero-padded decimal number.
Example:
01, 02, …, 12

In [12]:
day = now.strftime("%I") 
print("Hour as a zero-paddes decimal number:", day)
Hour as a zero-paddes decimal number: 02

Code - %p: Locale’s equivalent of either AM or PM.
Example:
AM, PM (en_US);
am, pm (de_DE)

In [13]:
day = now.strftime("%p") 
print("Locale's equivalent of either AM Or PM:", day)
Locale's equivalent of either AM Or PM: PM

Code - %M: Minute as a zero-padded decimal number.
Example:
00, 01, …, 59

In [14]:
day = now.strftime("%M") 
print("Minute as a zero-padded decimal number:", day)
Minute as a zero-padded decimal number: 25

Code - %S: Second as a zero-padded decimal number.
Example:
00, 01, …, 59

In [15]:
day = now.strftime("%S") 
print("Second as a zero-padded decimal number:", day)
Second as a zero-padded decimal number: 35

Code - %f: Microsecond as a decimal number, zero-padded on the left.
Example:
000000, 000001, …, 999999

In [16]:
day = now.strftime("%f") 
print("Microsecond as a decimal number, zero-padded on the left:", day)
Microsecond as a decimal number, zero-padded on the left: 711200

Code - %z: UTC offset in the form ±HHMM[SS[.ffffff]] (empty string if the object is naive).
Example:
(empty), +0000, -0400, +1030, +063415, -030712.345216

In [17]:
import time
from datetime import time, tzinfo, timedelta
class TZ1(tzinfo):
   def utcoffset(self, dt):
      return timedelta(hours=1)
   def dst(self, dt):
      return timedelta(0)
   def tzname(self,dt):
      return "+01:00"
   def  __repr__(self):
      return f"{self.__class__.__name__}()"
t = time(10, 8, 55, tzinfo=TZ1())
day = t.strftime("%z") 
print("UTC offset in the form ±HHMM[SS[.ffffff]]:", day)
UTC offset in the form ±HHMM[SS[.ffffff]]: +0100

Code - %Z: Time zone name (empty string if the object is naive).
Example:
(empty), UTC, EST, CST

In [18]:
import time
from datetime import time, tzinfo, timedelta
class TZ1(tzinfo):
   def utcoffset(self, dt):
      return timedelta(hours=1)
   def dst(self, dt):
      return timedelta(0)
   def tzname(self,dt):
      return "+01:00"
   def  __repr__(self):
      return f"{self.__class__.__name__}()"
t = time(10, 8, 55, tzinfo=TZ1())
day = t.strftime("%Z")
print("Time zone name:", day)
Time zone name: +01:00

Code - %j: Day of the year as a zero-padded decimal number.
Example:
001, 002, …, 366

In [19]:
day = now.strftime("%j") 
print("Day of the year as a zero-padded decimal number:", day)
Day of the year as a zero-padded decimal number: 240

Code - %U: 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.
Example:
00, 01, …, 53

In [20]:
day = now.strftime("%U") 
print("Week number of the year as a zero-padded decimal number:", day)
Week number of the year as a zero-padded decimal number: 34

Code - %W: 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.
Example:
00, 01, …, 53

In [21]:
day = now.strftime("%W") 
print("Week number of the year as a zero-padded decimal number:", day)
Week number of the year as a zero-padded decimal number: 34

Code - %c: Locale’s appropriate date and time representation.
Example:
Tue Aug 16 21:30:00 1988 (en_US);
Di 16 Aug 21:30:00 1988 (de_DE)

In [22]:
day = now.strftime("%c") 
print("Locale's appropriate date and time representation:", day)
Locale's appropriate date and time representation: Wed Aug 28 14:25:35 2019

Code - %x: Locale’s appropriate date representation.
Example:
08/16/88 (None);
08/16/1988 (en_US);
16.08.1988 (de_DE)

In [23]:
day = now.strftime("%x") 
print("Locale's appropriate date representation:", day)
Locale's appropriate date representation: 08/28/19

Code - %X: Locale’s appropriate time representation.
Example:
21:30:00 (en_US);
21:30:00 (de_DE)

In [24]:
day = now.strftime("%X") 
print("Locale's appropriate time representation:", day)
Locale's appropriate time representation: 14:25:35

Code - %%: A literal '%' character.
Example:
%

In [25]:
day = now.strftime("%%") 
print("A literal '%' character:", day)
A literal '%' character: %

Several additional directives not required by the C89 standard are included for convenience.
These parameters all correspond to ISO 8601 date values. These may not be available on all platforms when used with the strftime() method.
The ISO 8601 year and ISO 8601 week directives are not interchangeable with the year and week number directives above.
Calling strptime() with incomplete or ambiguous ISO 8601 directives will raise a ValueError.

Code - %G: ISO 8601 year with century representing the year that contains the greater part of the ISO week (%V).
Example:
0001, 0002, …, 2013, 2014, …, 9998, 9999

In [26]:
day = now.strftime("%G") 
print("ISO 8601 year with century representing the year that contains the greater part of the ISO week:", day)
ISO 8601 year with century representing the year that contains the greater part of the ISO week: 2019

Code - %u: ISO 8601 weekday as a decimal number where 1 is Monday.
Example:
1, 2, …, 7

In [27]:
from datetime import datetime
now = datetime.now()
day = now.strftime("%u") 
print("ISO 8601 weekday as a decimal number where 1 is Monday:", day)
ISO 8601 weekday as a decimal number where 1 is Monday: 3

Code - %V: ISO 8601 week as a decimal number with Monday as the first day of the week. Week 01 is the week containing Jan 4.
Example:
01, 02, …, 53

In [28]:
day = now.strftime("%V") 
print("ISO 8601 week as a decimal number with Monday as the first day of the week.:", day)
ISO 8601 week as a decimal number with Monday as the first day of the week.: 35

New in version 3.6: %G, %u and %V were added.