Parse date string and change format

0 votes
I want to change the date format to '15/02/2010'. How can I do this?
Apr 25 in Python by Kichu
• 16,050 points
12 views

1 answer to this question.

0 votes

Use datetime module. it can help you change the format.

datetime.datetime.strptime(date_string, format1).strftime(format2)

For a specific example:

>>> import datetime

>>> datetime.datetime.strptime('Mon Feb 15 2010', '%a %b %d %Y').strftime('%d/%m/%Y')

'15/02/2010'

>>>

I hope this helps.

answered Apr 25 by narikkadan
• 7,860 points

Related Questions In Python

0 votes
1 answer

Change date and time format in Python.

Try the following code: date=time.split(‘ ’) time=dat ...READ MORE

answered May 8, 2019 in Python by Sagar
288 views
0 votes
1 answer

How to parse date/time string with timezone abbreviated name in Python?

The parse() function in dateutil can't handle ...READ MORE

answered Nov 27, 2018 in Python by Nymeria
• 3,540 points
1,163 views
0 votes
1 answer

How to change the default Django date template format?

Hello @kartik, Within your template, you can use ...READ MORE

answered Aug 7, 2020 in Python by Niroj
• 82,680 points
2,727 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 2,755 views
0 votes
1 answer
0 votes
1 answer

Detect and exclude outliers in a pandas DataFrame

Function definition. This handles data when non-numeric attributes ...READ MORE

answered Apr 28 in Python by narikkadan
• 7,860 points
63 views
0 votes
1 answer

ValueError: could not convert string to float: id

The problem is that in your code ...READ MORE

answered Apr 28 in Python by narikkadan
• 7,860 points
60 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP