I am receiving twitter messages that are sent at a certain date in the following format from twitter:
Tue Mar 29 08:11:25 +0000 2011
I want
How about this? It doesn't need any formatting strings.
import datetime
from email.utils import mktime_tz, parsedate_tz
def parse_datetime(value):
time_tuple = parsedate_tz(value)
timestamp = mktime_tz(time_tuple)
return datetime.datetime.fromtimestamp(timestamp)
print(parse_datetime('Tue Mar 29 08:11:25 +0000 2011'))
#2011-03-29 10:11:25
My system is at GMT +2 hence the difference included.