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, 2022 in Python by Kichu
• 19,040 points
595 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, 2022 by narikkadan
• 63,600 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
716 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,560 points
2,293 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,840 points
4,471 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 4,467 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, 2022 in Python by narikkadan
• 63,600 points
3,805 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, 2022 in Python by narikkadan
• 63,600 points
8,757 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP