0

From an API response, I am getting the following value for 'created_at' field:

 {'created_at': u'Mon Jul 08 12:00:16 +0000 2013'}

In order to convert 'Mon Jul 08 12:00:16 +0000 2013' to python datetime object, I have tried different cases with 'datetime.strptime()' but nothing found working.

Can anyone suggest a solution for this.

user3666197
  • 1
  • 6
  • 50
  • 92
Akhil Sundar
  • 1,267
  • 5
  • 18
  • 32
  • Please provide the code you tried and the problems you encountered. – bereal Oct 30 '14 at 09:42
  • You may want to read **whathaveyoutried.com** & show some respect to the StackOverflow Community, which strongly encourages to post high quality questions, altogether with a MCVE ( **a Minimum-Complete-Verifiable-Example of code** ) showing what-you-have-tried so far. You may want to update your post, so as to meet this minimum reasonable level of quality & **to show your will** to respect other StackOverflow contributing members. They are professionals who love to answer good questions on MCVE-related issues. **Enjoy being StackOverflow Member & do support this Community Netiquette** – user3666197 Oct 30 '14 at 09:45
  • Try https://labix.org/python-dateutil – georg Oct 30 '14 at 09:46
  • for more inspiration, you may kindly try searching StackOverflow for already answered questions on the same or a similar subject. >>> http://stackoverflow.com/a/22223725/3666197 **may help you get further to an MCVE** – user3666197 Oct 30 '14 at 09:47
  • related: [Python: parsing date with timezone from an email](http://stackoverflow.com/a/23117071/4279) – jfs Oct 30 '14 at 09:51
  • 2
    Actually, this question is not exactly a duplicate! The ``+0000`` part is unique for this date string. Most importantly, simple ``%z`` which corresponds to that timezone format won't work for everyone because it only in ``Python 3.2+``. – go2 Oct 30 '14 at 09:54
  • @go2: have you tried it? [The answer works as is](http://stackoverflow.com/a/26435566/4279) (It works on both Python 2.7, and Python 3). I've linked above to [the answer that works on Python 2.6+](http://stackoverflow.com/a/23117071/4279) if you need it. – jfs Oct 30 '14 at 10:48
  • @J.F.Sebastian My comment is referring to the duplicate displayed on top of the original question (e.g. Converting string...). Sorry, I didn't see you previous comment here (e.g. related Python: parsing....). Finally, I should indicate that my comment relates to the use of ``datetime.strptime()``. – go2 Oct 30 '14 at 10:54
  • @go2: yes, I'm talking about [**the answer to the duplicate question**. I don't see strptime() in it at all](http://stackoverflow.com/a/26435566/4279). For an answer, look in the answers, not in the question. – jfs Oct 30 '14 at 10:55
  • @J.F.Sebastian I never said that there was ``strptime()`` in it. What I mean, is that I started writing my initial comment before yours was posted. Hence, my comment is still valid as an advice if someone wants to use ``datetime.strptime()``. – go2 Oct 30 '14 at 11:01

0 Answers0