How to Get Current Year in Python?

By Hardik Savani October 30, 2023 Category : Python

Hi Dev,

In this short tutorial we will cover an python get current year. step by step explain how to get current year in python. In this article, we will implement a how to get current year in python 3. you can understand a concept of python get today year. you will do the following things for python get current year as decimal number.

In this post, i will give you three examples to getting current year in python. we will use datetime module to get current year from date. so let's see following examples with output:

Example 1:

from datetime import datetime
today =
print("Current Date and Time :", today)
print("Current Year :", today.year)


Current Date and Time : 2022-05-31 09:21:35.126001
Current Year : 2022

Example 2:

from datetime import datetime
today =
year = today.strftime("%-y")
print("Current Year as decimal number :", year);


Current Year as decimal number : 22

I hope it can help you...

Tags :