Skip to content

Commit

Permalink
Fixed #35267 -- Clarified time zone topic for PostgreSQL in docs.
Browse files Browse the repository at this point in the history
The timezone documentation for Postgres mentions the behavior of
time zone conversion, but links to the wrong setting that controls the
behavior.

Postgres will not return datetimes in the time zone set by the
TIME_ZONE setting, but rather the time zone of the database connection,
which is defined by DATABASES.TIME_ZONE setting falling back to UTC.

This corrects the link in the documentation and adds note that there
are two distinct TIME_ZONE settings and the one most are familiar with
is not considered for PostgreSQL time zone conversion.
  • Loading branch information
jarshwah authored and felixxm committed Mar 5, 2024
1 parent ab22b7c commit 6e195b8
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions docs/topics/i18n/timezones.txt
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,15 @@ UTC on storage, and from UTC to the connection's time zone on retrieval.

As a consequence, if you're using PostgreSQL, you can switch between ``USE_TZ
= False`` and ``USE_TZ = True`` freely. The database connection's time zone
will be set to :setting:`TIME_ZONE` or ``UTC`` respectively, so that Django
obtains correct datetimes in all cases. You don't need to perform any data
conversions.
will be set to :setting:`DATABASE-TIME_ZONE` or ``UTC`` respectively, so that
Django obtains correct datetimes in all cases. You don't need to perform any
data conversions.

.. admonition:: Time zone settings

The :setting:`time zone <DATABASE-TIME_ZONE>` configured for the connection
in the :setting:`DATABASES` setting is distinct from the general
:setting:`TIME_ZONE` setting.

Other databases
~~~~~~~~~~~~~~~
Expand Down

0 comments on commit 6e195b8

Please sign in to comment.