Skip to content

Instantly share code, notes, and snippets.

@juehan
Created February 15, 2012 15:08
Show Gist options
  • Select an option

  • Save juehan/1836517 to your computer and use it in GitHub Desktop.

Select an option

Save juehan/1836517 to your computer and use it in GitHub Desktop.
Example to show how to change timezone using *nix environment variable
'''
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