Write dates as datetime objects

0 votes

I have a large list of dates in this format stored as a string type:

Mar 22 2012 5:00PM
Aug 23 2012 6:00AM

How can I convert these into a datetime object in python?

Apr 18, 2018 in Python by backendguy
420 views

1 answer to this question.

0 votes
from datetime import datetime

datetime_object = datetime.strptime('Aug 23 2012  6:00AM', '%b %d %Y %I:%M%p')
answered Apr 18, 2018 by Nietzsche's daemon
• 4,260 points

Related Questions In Python

+1 vote
4 answers

How to write nested dictionaries to a CSV file

Using DictWriter there is no need in ...READ MORE

answered Oct 18, 2018 in Python by Richard William
26,726 views
+1 vote
4 answers

How can I concatenate str and int objects?

If you want to concatenate int or ...READ MORE

answered Oct 18, 2018 in Python by subhm
890 views
0 votes
1 answer

How can I write nested dictionaries to a csv file?

You can use the pandas library to ...READ MORE

answered Apr 17, 2018 in Python by anonymous
913 views
0 votes
1 answer

Compare dates

>>> from datetime import datetime >>> past = ...READ MORE

answered Jun 14, 2018 in Python by Hamartia's Mask
• 1,580 points
472 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,023 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
3,409 views
0 votes
1 answer

Number of days between dates in Python

You can use the date module to ...READ MORE

answered May 30, 2018 in Python by Nietzsche's daemon
• 4,260 points
410 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