Hackerss.com

Hackerss.com is a community of amazing hackers

Hackerss is a community for developers, data scientitst, ethical hackers, hardware enthusiasts or any person that want to learn / share their knowledge of any aspect of digital technology.

Create account Log in
hackerss
hackerss

Posted on

print date in specific format in Python

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


Enter fullscreen mode Exit fullscreen mode

Top comments (0)