[Fixed]-Values() returns datetime with tzinfo = UTC in default, can I change the default timezone before calling values()?

1👍

When you use timezone.now() it’s using the zone define in the settings.py by default but you can change it, see the documentation about selecting the current time zone.

You have 3 choices:

  • MIDDLEWARE
  • View
  • Template

Don’t forget to install pytz for using midlleware or view : pip install pytz. Else if you to do it in the template:

{% load tz %}

{% timezone "Europe/Paris" %}
    Paris time: {{ value }}
{% endtimezone %}

{% timezone None %}
    Server time: {{ value }}
{% endtimezone %}

Leave a comment