print date in specific format - Python:
import datetime
def print_date(date):
"""
Print a date in the format "YYYY-MM-DD".
Parameters
----------
date : datetime.date
The date to print.
"""
#print the date in the format "YYYY-MM-DD"
print(date.strftime("%Y-%m-%d"))
#example
print_date(datetime.date(2020, 1, 1)) #2020-01-01
Top comments (0)