Reputation: 129
I want to convert the date format from Wed Aug 16 2017
to 16/08/2017
Here is the code I tried:
datetime_object = datetime.strptime(newList[0], '%a %b %d %Y').date()
datetime_object = datetime.strptime(str(datetime_object), '%Y-%m-%d').strftime('%d/%m/%y')
print datetime_object
Upvotes: 1
Views: 3450
Reputation: 11082
Try this
import datetime
dateTime = datetime.datetime.strptime("Wed Aug 16 2017", "%a %b %d %Y")
print dateTime.strftime('%d/%m/%Y')
This gives you datetime object object, out of that you can format it however you want
Upvotes: 1