[Answered ]-Getting correct local time zone to display for end-users in Django web app

2👍

the use of {% localtime on %} is correct, but you need to activate your user’s timezone before you can use that. Django does not automatically knows your user’s tz.

https://docs.djangoproject.com/en/1.8/ref/utils/#django.utils.timezone.activate

# py
settings.TIME_ZONE = 'UTC'
timezone.activate('us/estern')

# template
{% localtime on %}
{{ datetime }} <= this time will be in estern standard time
👤Du D.

Leave a comment