I have django project with TIME_ZONE = 'America/Chicago'
set in settings.py.
I am using dates like this:
from django.utils.dateparse import parse_datetime
import datetime
from datetime import datetime
dateobject = parse_datetime(some_string)
now = datetime.now()
if now > dateobject:
# do something
Then in template I use:
dateobject|date:"d M Y H:i"
All I want to display dates in ALL my templates in different time zone (for example +6 hours). But I want project timezone to be 'America/Chicago' and date returned by datetime.now() was in this timezone. So I just want to change all dates DISPLAYED to be +6 hours for example. How I can accomplish this?
edit
Okay this works for me:
{% load tz %}
{{ datetimevalue|timezone:"Europe/Paris" }}
It prints date with +1 hour. But this doesn't work:
{% load tz %}
{% timezone "Europe/Paris" %}
{{ datetimevalue }}
{% endtimezone %}
It prints date unchanged. I have to set it globally for all templates. How I can do it?
I always use date filter (dateobject|date:"d M Y H:i"
) so maybe is there any way to "hook" this filter globally to change it to dateobject|timezone:"Europe/Paris"|date:"d M Y H:i"
?