Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Python Programming Language

convert time string in UTC to time in local time


I'm guessing there is an easy way to do this but I keep going around  
in circles in the documentation.

I have a time stamp that looks like this (corresponding to UTC time):

start_time = '2007-03-13T15:00:00Z'

I want to convert it to my local time.

start_time = time.mktime(time.strptime(start_time, '%Y-%m-%dT%H:%M:
00Z'))
start_time -= time.timezone

This was working fine now, but if I do it for a date next week (such  
as March 13th in the above example), it breaks because my local time  
moves to daylight savings time this weekend. So my time is now off by  
an hour. I'm guessing if I try this next week it will work okay  
because time.timezone will be give a different value next week - is  
that correct?

Is there a direct way to convert that timestamp in UTC to a local  
time stamp that will always work?

TIA,
Dave

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc