How to Get the Current Year, Month, and Day as Integers in Python 3 using the datetime Module

This blog post is brought to you by the developer of BitBudget. BitBudget is an automated budgeting app for Android and iOS which syncs with your bank account and helps you avoid overspending. If you’d like to quit living paycheck-to-paycheck and get a better handle on your finances, download it today! https://bitbudget.io

Currently working on a project where I need to get the current year, month, and day as integers in Python 3, and noticed that the #1 ranked Google search result for my search resulted in an old answer written in Python 2. While I guess it’s not really a big deal, here is my updated Python 3 code (nothing is different other than the print statements, lol):

# REFERENCE: https://bit.ly/2JtjSto
import datetime
now = datetime.datetime.now()
print(now.year)
print(now.month)
print(now.day)
 

topherPedersen