Skip to content

Instantly share code, notes, and snippets.

@robertklep
Created June 14, 2012 05:46
Show Gist options
  • Save robertklep/2928188 to your computer and use it in GitHub Desktop.
Save robertklep/2928188 to your computer and use it in GitHub Desktop.
Convert RFC822 timestamp string to datetime object in Python
from datetime import datetime
import email
# convert RFC822 timestamp string to datetime object
def rfc822(timestamp):
return datetime.fromtimestamp(email.Utils.mktime_tz(email.Utils.parsedate_tz(timestamp)))
if __name__ == '__main__':
import sys
print rfc822(sys.argv[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment