0

How can I parse a datetime string in this format 'Mon, 04 Aug 2014 10:26:20 GMT' to compare it to the current date ?

MayK
  • 1,269
  • 1
  • 10
  • 24
  • Show us what you have tried. How did you use https://docs.python.org/3.4/library/datetime.html#strftime-strptime-behavior? –  Aug 05 '14 at 09:38

1 Answers1

0

You have to use datetime.strptime

>>> from datetime import datetime
>>> datetime.strptime(a, "%a, %d %b %Y %H:%M:%S %Z")
datetime.datetime(2014, 8, 4, 10, 26, 20)

This will convert your string to datetime object which you can use for further process.

Nilesh
  • 20,521
  • 16
  • 92
  • 148