Skip to content

Instantly share code, notes, and snippets.

@nqthqn
Created April 20, 2016 16:29
Show Gist options
  • Save nqthqn/21ec2cef73106fe5211ec8d226ee71ec to your computer and use it in GitHub Desktop.
Save nqthqn/21ec2cef73106fe5211ec8d226ee71ec to your computer and use it in GitHub Desktop.
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)
@nqthqn
Copy link
Author

nqthqn commented Apr 20, 2016

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