Skip to content

Instantly share code, notes, and snippets.

@kitsunde
Created September 7, 2012 12:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kitsunde/3665628 to your computer and use it in GitHub Desktop.
Save kitsunde/3665628 to your computer and use it in GitHub Desktop.
pytz working for Singapore
>>> import pytz
>>> from datetime import datetime
>>> time_zone = pytz.timezone('Asia/Singapore')
>>> my_time = datetime.utcnow()
>>> my_time
datetime.datetime(2012, 9, 7, 12, 6, 15, 56631)
>>> my_time.replace(tzinfo=pytz.utc)
datetime.datetime(2012, 9, 7, 12, 6, 15, 56631, tzinfo=<UTC>)
>>> my_time = my_time.replace(tzinfo=pytz.utc)
>>> my_time.astimezone(time_zone)
datetime.datetime(2012, 9, 7, 20, 6, 15, 56631, tzinfo=<DstTzInfo 'Asia/Singapore' SGT+8:00:00 STD>)
>>>
@khzaw
Copy link

khzaw commented Jun 15, 2021

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment