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

.



Relevant Pages

  • Re: fsck died with nexit status 8
    ... time of install the system clock is not set in some distros or your ... local time gets set as EST which means that at next boot in terms ... behaving presumably because your local time stamp is now atleast equal ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)
  • Re: File Date and Time stamp after FileStream.Write(), C#
    ... running app tests on my Dell Axim Pocket PC device, ... It has been the memory card installation that has been the change and is ... where I noticed the time stamp differences. ... in device memory uses local time. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Storing Date/Time with Daylight savings
    ... it will have a Time Stamp column and other columns to save real ... saved in the Time Stamp; I can use either System Time or Local Time; ... Local Time, I can have problems with Daylight saving. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: File Date and Time stamp after FileStream.Write(), C#
    ... newly created files had the time stamp of the local time. ... I have just noticed in my CF app on a Pocket PC (PPC) that when I create ... stamp displayed in the Modified column in Windows Explorer on the ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: 1976s PCGS PR69DC - HELP A NEWBIE!
    ... Is your computer's system clock running fast? ... Can't think of any other reason for your posts's time stamp to be so ... I'm guessing that you're posting from a Pacific Time Zone location. ... I also had the RCC messages mis-sorted and didn't see the previous responses in this thread, so the message (not just the time stamp) was also confusing. ...
    (rec.collecting.coins)