Home  »  CodeSnippets   »   Get the Current Year in Python

Get the Current Year in Python

Posted: February 6, 2022 | by Michael Bright

Using DateTime:

import datetime
now = datetime.datetime.now().year
print(now)

or:

from datetime import date
year = date.today().year
print(year)

Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.