Generate date from day, month and year in Python

Earlier we have seen how to get the current date in Python programming. Now we will see hot to generate date from separate day, month and year values. The best and the simplest way to generate a date is by using the date() object of datetime module. The date() object takes 3 arguments (year, month, day) . Here is an example of generating a date in the datetime.date type from integer vales of year, month and day.

import datetime

year = 2016
month = 11
day = 25

date = datetime.date(year, month, day)
print("\n", date, "\n")
print("\n", type(date), "\n")
Generate date from day, month and year in Python

Reference

Related Articles & Tools

Leave your thoughts...

This site uses Akismet to reduce spam. Learn how your comment data is processed.