Source Code:
(back to article)
from datetime import datetime dt = datetime(2022, 1, 16, 12, 30, 45) date_string = dt.strftime('%Y-%m-%d') print(date_string) # Output: '2022-01-16'
Result:
Report an issue