Getting today's date in YYYY-MM-DD in Python?

I'm using:

    str(datetime.datetime.today()).split()[0]

to return today's date in the form YYYY-MM-DD.

Is there a less crude way to achieve this?

You can use strftime:

    datetime.datetime.today().strftime('%Y-%m-%d')

From: stackoverflow.com/q/32490629