Created
February 4, 2013 20:31
-
-
Save vortec/4709504 to your computer and use it in GitHub Desktop.
.strftime('%s') is locale-aware
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 pytz import timezone | |
| from datetime import datetime | |
| # From http://en.wikipedia.org/wiki/Eastern_Time_Zone | |
| # "Places that use Eastern Standard Time (EST) when observing standard time (autumn/winter) | |
| # are 5 hours behind Coordinated Universal Time (UTC−05:00)." | |
| us = timezone('US/Eastern') | |
| # GMT during the winter is exactly UTC if I'm not mistaken | |
| uk = timezone('Europe/London') | |
| us_time = datetime.now(us) | |
| uk_time = datetime.now(uk) | |
| us_timestamp = int(us_time.strftime('%s')) | |
| uk_timestamp = int(uk_time.strftime('%s')) | |
| diff = (us_timestamp - uk_timestamp) / 60 / 60 | |
| print diff ## -5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment