convert time string in UTC to time in local time
- From: davelist@xxxxxxx
- Date: Thu, 8 Mar 2007 16:57:15 -0500
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
.
- Follow-Ups:
- Re: convert time string in UTC to time in local time
- From: Paul Boddie
- Re: convert time string in UTC to time in local time
- Prev by Date: Re: SQLAlchemy and Oracle Functions?
- Next by Date: Re: Dyanmic import of a class
- Previous by thread: What is the best way to upgrade python?
- Next by thread: Re: convert time string in UTC to time in local time
- Index(es):
Relevant Pages
|