Open In App

Python program to print current year, month and day

In this article, the task is to write a Python Program to print the current year, month, and day.

Approach:




# importing date class from datetime module
from datetime import date
  
# creating the date object of today's date
todays_date = date.today()
  
# printing todays date
print("Current date: ", todays_date)
  
# fetching the current year, month and day of today
print("Current year:", todays_date.year)
print("Current month:", todays_date.month)
print("Current day:", todays_date.day)

Output:

Current date:  2020-12-10
Current year: 2020
Current month: 12
Current day: 10
Article Tags :