Skip to content

Instantly share code, notes, and snippets.

@shvechikov
Last active October 1, 2015 07:18
Show Gist options
  • Save shvechikov/1944246 to your computer and use it in GitHub Desktop.
Save shvechikov/1944246 to your computer and use it in GitHub Desktop.
Using timezones in python
import time
import datetime
import pytz
def utc_timestamp(dt, tz):
tz = pytz.timezone(tz)
return int(time.mktime(dt.replace(tzinfo=tz).utctimetuple()))
print utc_timestamp(datetime.datetime.now(), 'Europe/Moscow')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment