Last active
August 29, 2015 14:18
-
-
Save ccwang002/2287da0da0bc970fe7df to your computer and use it in GitHub Desktop.
Timezone Conversion
This file contains hidden or 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
from datetime import datetime | |
from pytz import timezone # pip install pytz | |
# Setup remote time | |
remote_tz = timezone('US/Pacific') # PST for example | |
remote_dt = remote_tz.localize(datetime(2015, 5, 1, 14, 0)) # May 1, 2015 PM2:00 PST | |
# Setup Taipei local time | |
tpe = timezone('Asia/Taipei') | |
# Conversion | |
local_dt = remote_dt.astimezone(tpe) | |
print(local_dt) # May 2, 2015 AM5:00 CST |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment