Created
May 29, 2014 00:37
-
-
Save mebusw/48ef02090b2156407a1c to your computer and use it in GitHub Desktop.
timezone and datetime in Django
This file contains 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 django.utils import timezone | |
# Suppose in settings.py, TIME_ZONE = 'Asia/Shanghai' | |
timezone.now() | |
# >>> datetime.datetime(2014, 5, 29, 0, 35, 19, 523838, tzinfo=<UTC>) | |
timezone.localtime(timezone.now()) | |
# >>> datetime.datetime(2014, 5, 29, 8, 35, 29, 427944, tzinfo=<DstTzInfo 'Asia/Shanghai' CST+8:00:00 STD>) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment