Skip to content

Instantly share code, notes, and snippets.

@nsfyn55
Created May 21, 2012 21:34
Show Gist options
  • Save nsfyn55/2764877 to your computer and use it in GitHub Desktop.
Save nsfyn55/2764877 to your computer and use it in GitHub Desktop.
Timezone Hours Offset
import pytz
from pytz import timezone
from datetime import datetime,timedelta
import time
utc = pytz.utc
utc.zone
eastern = timezone("America/New_York")
loc_dt = eastern.localize(datetime.now())
offset = loc_dt.utcoffset()
if offset.days < 0:
seconds_off = loc_dt.utcoffset().seconds- (24*60*60)
else:
seconds_off = offset.seconds
print seconds_off/3600
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment