I have a date of the form specified by RFC 2822 -- say Fri, 15 May 2009 17:58:28 +0000
, as a string. Is there a quick and/or standard way to get it as a datetime
object in Python 2.5? I tried to produce a strptime format string, but the +0000 timezone specifier confuses the parser.
views:
802answers:
3
+8
A:
There is a parsedate function in email.util. It parses all valid RFC 2822 dates and some special cases.
ebo
2009-05-19 21:10:19
+9
A:
from email.utils import parsedate
print parsedate('Fri, 15 May 2009 17:58:28 +0000')
nosklo
2009-05-19 21:11:14
+1 I didn't know about this function, really neat.
Nadia Alramli
2009-05-19 21:14:48
Thank you; that does the trick. :)
millenomi
2009-05-20 07:21:02