79772769

Date: 2025-09-23 15:07:23
Score: 0.5
Natty:
Report link

Objects of the date type are always naive.

https://docs.python.org/3/library/datetime.html#determining-if-an-object-is-aware-or-naive

Therefore, construct a UTC datetime and get its date

import datetime
date = datetime.datetime.now(tz=datetime.timezone.utc).date()
print(date)  # 2025-09-23

My personal opinion, though? Keep the aware datetime instead of just the date. You can always call .date() on it, or create a new aware datetime with the hours, minutes, seconds, and microseconds removed.

Reasons:
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (0.5):
Posted by: gabelepoudre