Azimout's Linux weblog

Local timezone offset in Python

leave a comment »

I wanted to get the local timezone’s offset (in minutes or even hours) inside Python. Google has been unhelpful (lots of forums and bug reports saying it’s complicated/not implemented).

I found out the simple solution by mistake: the answer is not found in the datetime module but in the time module (the answer is UTC – LOCAL in seconds):

import time


Written by azimout

22/02/2011 at 12:16

Posted in Howto

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: