'Convert time to simple format
I want to convert this time 2022-02-24T01:44:22 to 02/24/2022
since_date = 2022-02-24T01:44:22
print (since_date.strftime("%m/%d/%Y"))
Error:
AttributeError: 'str' object has no attribute 'strftime'
Solution 1:[1]
This should work for your case:
from datetime import datetime
date = datetime.strptime('2022-02-24T01:44:22', '%Y-%m-%dT%I:%M:%S').strftime("%m/%d/%y")
print(date)
check this link for other types of formatting.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
