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
17 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
4,203 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
42 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
117 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
20 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,520 points
20 views
+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 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 172 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
31 views