Python – How to convert a datetime to date

datetimepython

How do I convert a datetime.datetime object (e.g., the return value of datetime.datetime.now()) to a datetime.date object in Python?

Best Solution

Use the date() method:

datetime.datetime.now().date()