[Tutor] datetime.strptime not matching timezone in format

vishwajeet singh dextrous85 at gmail.com
Tue May 4 12:52:13 CEST 2010


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 ?

However I do not have a solution to your problem but a footnote as hint -
> http://docs.python.org/library/time.html#id1
>
>
Thanks for the link I am browsing this from morning not much of help there.


> -- Abhishek
>
> On Tue, May 4, 2010 at 3:17 PM, vishwajeet singh <dextrous85 at gmail.com>wrote:
>
>> Dear All,
>>
>> I am trying to convert date string to datetime using datetime.strptime and
>> when there is timezone part in string conversion is throwing errors.
>>
>>  Here is what I am doing
>> string_date = somedate.strftime("%a, %d %b %Y %H:%M:%S %Z")
>>
>> and than later in some other part of code
>> actual_date = datetime.strptime(string_date,"%a, %d %b %Y %H:%M:%S %Z")
>>
>> I am getting following error for this conversion "*time data 'Tue, 04 May
>> 2010 14:59:45 +05:30' does not match format '%a, %d %b %Y %H:%M:%S %Z'*"
>>
>>  All formats without timezone works perfectly fine.
>>
>> --
>> Vishwajeet Singh
>> +91-9657702154 | dextrous85 at gmail.com | http://bootstraptoday.com
>> Twitter: http://twitter.com/vishwajeets | LinkedIn:
>> http://www.linkedin.com/in/singhvishwajeet
>>
>> _______________________________________________
>> Tutor maillist  -  Tutor at python.org
>> To unsubscribe or change subscription options:
>> http://mail.python.org/mailman/listinfo/tutor
>>
>>
>


-- 
Vishwajeet Singh
+91-9657702154 | dextrous85 at gmail.com | http://bootstraptoday.com
Twitter: http://twitter.com/vishwajeets | LinkedIn:
http://www.linkedin.com/in/singhvishwajeet
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100504/dc405e66/attachment.html>


More information about the Tutor mailing list