Created
November 7, 2016 17:24
-
-
Save tadeck/0d4bc636afc4bdc6a6291ee45bc0aae8 to your computer and use it in GitHub Desktop.
How to convert local time to different UTC time stamps depending on whether there is, or there isn't DST in effect
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
| >>> import pytz | |
| >>> from datetime import datetime | |
| >>> pytz.timezone('US/Mountain').localize(datetime(year=2016, month=11, day=3, hour=12, minute=0)).astimezone(pytz.UTC).isoformat() | |
| '2016-11-03T18:00:00+00:00' | |
| >>> pytz.timezone('US/Mountain').localize(datetime(year=2016, month=11, day=7, hour=12, minute=0)).astimezone(pytz.UTC).isoformat() | |
| '2016-11-07T19:00:00+00:00' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment