[Tutor] datetime.strptime not matching timezone in format

Abhishek Mishra ideamonk at gmail.com
Tue May 4 13:07:08 CEST 2010


On Tue, May 4, 2010 at 4:22 PM, vishwajeet singh <dextrous85 at gmail.com>wrote:

>
> On Tue, May 4, 2010 at 4:17 PM, Abhishek Mishra <ideamonk at gmail.com>wrote:
>
>> %Z stands for time zone name in letters Eg. IST or EDT or GMT, so it would
>> fail to parse +05:30
>>
>>    Ahh...ok thanks for pointing that out but this is kind of stranges as I
> am using same format to convert than why it's not converting it in IST ?
>
>
Interestingly, I guess the timezone environment variable is not set on my
system .

>>> datetime.today()
datetime.datetime(2010, 5, 4, 16, 25, 28, 381390)
>>> d = datetime.today()
>>> string_date = d.strftime("%a, %d %b %Y %H:%M:%S %Z")
>>> string_date
'Tue, 04 May 2010 16:25:32 '
>>>
^^ notice absence of time zone

An interesting discussion on same issue -
http://old.nabble.com/strptime-and-timezones-td18967515.html

>>> import time
>>> time.tzname
('IST', 'IST')
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100504/79ee38c7/attachment.html>


More information about the Tutor mailing list