1

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

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

My input for date is Wed Aug 16 2017. Please see the input properly

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.