Skip to main content

Get Day Month Year from Date Object in Python

Python provides a number of ways to manipulate dates and times. In this blog post, we will show you how to get the day month year from a date object in Python. This is a common operation that developers need to perform when working with dates.

To print the day, month, and year from this date object, we can use the strftime() method or day, month, and year properties.

import datetime
date = datetime.date(2022, 5, 15)
print(date.strftime('%d %b %Y')) #15 May 2022
print(date.strftime('%d')) #15
print(date.strftime('%m')) #5
print(date.strftime('%Y')) #2022

date = datetime.date(1990, 10, 30)
print(date.day) #30
print(date.month) #10
print(date.year) #1990

By continuing to use the site, you agree to the use of cookies.