I am trying to parse timestamp strings containing timezone information. When I execute the following on Python 2.5
from datetime import datetime
datetime.strptime("20120805-18:30:00 EST", "%Y%m%d-%H:%M:%S %Z")
I get:
ValueError: time data did not match format: data=20120805-18:30:00 EST fmt=%Y%m%d-%H:%M:%S %Z
However I change “EST” to “JST” the line executes fine (working on a Japan server). Also one more thing I noticed was time.tzname returns a list with only ‘JST’.
Is there a way to be able to parse all the usual timezones?
You can try to employ http://pytz.sourceforge.net/ for this. Standard
datetimedoesn’t know EST/PST.