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
648 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
27,807 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
1,311 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
1,215 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
654 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,466 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
4,127 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
593 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