Last active
October 1, 2015 07:18
-
-
Save shvechikov/1944246 to your computer and use it in GitHub Desktop.
Using timezones in python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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