I have a time datetime object.. which has both date and time..
so for example
d = (2011,11,1,8,11,22) (24 hour time time format)
But this time stamp is in mountain standard time.. (Arizona. phoenix)
Now I want to convert this time in EST...
Now that is just the time delta adjustment..
But then there is this daylight saving issues as well.
I was wondering if there is an inbuilt method to take care of daylight saving for adjusting time zones..
Use pytz for timezone conversions. pytz takes daylight savings in consideration check this. U need a helper function like:
def convert(dte, fromZone, toZone):
fromZone, toZone = pytz.timezone(fromZone), pytz.timezone(toZone)
return fromZone.localize(dte, is_dst=True).astimezone(toZone)
The library you're looking for is pytz, specifically the localize() method.
Pytz isn't in the standard library but you can get it with pip or easy_install.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With