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
8 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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
2,523 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
29 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
70 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
15 views
0 votes
1 answer

Correct way to write line to file?

This should be as simple as: with open('somefile.txt', ...READ MORE

answered Aug 3, 2018 in Python by Priyaj
• 56,120 points
15 views
0 votes
1 answer

how can i count the items in a list?

suppose you have a list a = [0,1,2,3,4,5,6,7,8,9,10] now ...READ MORE

answered May 2 in Python by Mohammad
• 1,400 points
22 views
+4 votes
6 answers
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
24 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.