python – How do I convert a datetime to date?
python – How do I convert a datetime to date?
Use the date()
method:
datetime.datetime.now().date()
From the documentation:
Return date object with same year, month and day.
python – How do I convert a datetime to date?
You use the datetime.datetime.date()
method:
datetime.datetime.now().date()
Obviously, the expression above can (and should IMHO 🙂 be written as:
datetime.date.today()