Timezones in python

Matt Nordhoff mnordhoff at mattnordhoff.com
Wed Dec 5 03:51:00 EST 2007


lukasz.f24 at gmail.com wrote:
> Is there any build in solution in python to handle timezones? My
> problem is I have to convert +4 time to +0. In the worst case i can
> just add +4 to the houer but I'm not very happy about that. Another
> problem is the summer/winter timechange which happen with one week
> difference. I am looking for something what can convert different
> timezone to localtime.

There's the pytz library [1] [2], which uses the tz database popular on
Unix systems, and python-dateutil [3] [4] also includes support for it,
among doing other date- and time-related things.

Those support time zone names (America/New_York or EST5EDT), and also
converting between them. If you only want to convert between +4 and +0,
without giving names for them, you don't need them, but I don't know how
to do it. Using UTC internally and only converting to other zones when
reading data in and displaying it makes things simpler . .

[1] <http://pytz.sourceforge.net/>
[2] <http://pypi.python.org/pypi/pytz>
[3] <http://labix.org/python-dateutil>
[4] <http://pypi.python.org/pypi/dateutil>
-- 



More information about the Python-list mailing list