Can I display the month name instead of a number?
Yes! By default we’re accessing the number value of the current month, day, year, minute, hour, and second of the day. We can customize a lot of how we display this.
We format the output using
strftime(), which won’t be discussed on Codecademy, but it’s a cool tool to have! For a full understanding of how to do it, take a look at the documentation for this method.
Take a look at the code below:
from datetime import datetime now = datetime.now() print(now.strftime('%B')) # Displays the current month’s name
strftime() that we want to display the month as its full name, and there are lots of other codes ready for use in the link above.