Possible Duplicate:
How to print date in a regular format in Python?
I would like to know how to convert the following date to natural language, including time zone in python?
input:
"'2012-09-27T02:00:00Z'"
expected output:
Wednesday, September 26 of 2012 Mountain Time
Thanks in advance!
Note Edit: So far I tried django humanize, although it doesn't handle very well complex date-time strings.
Solution:
Thanks for all the information. I ended up parsing the original string and using pitz and strftime like this:
my_date = '2012-09-27T02:00:00Z'
utc_date_object = datetime(int(my_date[0:4]), int(my_date[5:7]), int(my_date[8:10]),int(my_date[11:13]),int(my_date[14:16]),int(my_date[17:19]),0,pytz.utc)
mt_date_object = utc_date_object.replace(tzinfo=pytz.utc).astimezone(pytz.timezone('US/Mountain'))
natural_date = mt_date_object.strftime("%A, %B %d of %Y")
Output:
'Wednesday, September 26 of 2012'