Created
February 15, 2012 15:08
-
-
Save juehan/1836517 to your computer and use it in GitHub Desktop.
Example to show how to change timezone using *nix environment variable
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
| ''' | |
| module to get Sydney/Australia's local time. | |
| This module is not portable as time.tzset() is not supported at Windows Environment but only at *nix. | |
| Will be useful if deployment system is in different time zone to application's target time zone. | |
| ''' | |
| import os | |
| import time | |
| from time import strftime, localtime | |
| def getTime(): | |
| os.environ['TZ'] = 'Australia/Sydney' | |
| time.tzset() | |
| return strftime("%Y-%m-%d %H:%M:%S") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment