Created
April 20, 2016 16:29
-
-
Save nqthqn/21ec2cef73106fe5211ec8d226ee71ec to your computer and use it in GitHub Desktop.
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 | |
# pub_date is a models.DateTimeField | |
mytime = Question.objects.get(pk=1).pub_date.astimezone(pytz.timezone('US/Pacific')) | |
fmt = '%Y-%m-%d %H:%M:%S %Z%z' | |
mytime.strftime(fmt) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://docs.djangoproject.com/en/1.9/topics/i18n/timezones/