Source Code:
(back to article)
from datetime import datetime # Initialize a datetime object dt = datetime(2022, 1, 16, 12, 30, 45) # Convert to date object date_object = dt.date() print(date_object) # Output: 2022-01-16
Result:
Report an issue