Reputation: 193
I am relatively new to Django.
All of my datetime objects are in UTC and my settings.py file has TIME_ZONE = 'UTC'
When these datetime
objects show up in my html template using {{ obj.datetime }}, they are dislayed in UTC
, I want to display them in UTC-05:00.
How can I change this?
Note: I am using class-based views
Upvotes: 2
Views: 455
Reputation: 5854
You can change timezone global in your settings.py set:
TIME_ZONE = 'America/Panama'
for UTC-05:00
Or you can use filter timezone
in template - see Django documentation
{% load tz %}
{{ obj.datetime|timezone:"America/Atikokan" }}
{% timezone "America/Panama" %}
Panama time: {{ value }}
{% endtimezone %}
How can you see all available time zones?
pytz provides helpers, including a list of current time zones and a list of all available time zones – some of which are only of historical interest.
List of timezones from wikipedia: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
Upvotes: 3