Created
April 28, 2014 12:42
-
-
Save julienr/11370676 to your computer and use it in GitHub Desktop.
convert_timestamp.py
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
"""Convert UTC timestamp to custom timezone""" | |
import datetime | |
import pytz | |
import sys | |
assert len(sys.argv) > 1, 'Usage : convert_timestamp <timestamp>' | |
utc = pytz.utc | |
zurich = pytz.timezone('Europe/Zurich') | |
utc_dt = datetime.datetime.fromtimestamp(float(sys.argv[1]), tz=utc) | |
dt = utc_dt.astimezone(zurich) | |
print dt.strftime('%Y-%m-%d %H:%M:%S %Z%z') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment