1
0
mirror of https://github.com/django/django.git synced 2025-06-05 03:29:12 +00:00

[1.10.x] Fixed #26571 -- Corrected recommendation for converting timestamps to tz-aware datetimes.

Backport of d60386d0f5333c7fef4c5906a3358b00cf9de3bf from master
This commit is contained in:
Tim Graham 2016-08-19 14:47:06 -04:00
parent e5103de2d1
commit 33783a9e06

View File

@ -151,10 +151,8 @@ used.
backwards-compatibility with applications that still rely on local time. backwards-compatibility with applications that still rely on local time.
However, :ref:`as explained above <naive-datetime-objects>`, this isn't However, :ref:`as explained above <naive-datetime-objects>`, this isn't
entirely reliable, and you should always work with aware datetimes in UTC entirely reliable, and you should always work with aware datetimes in UTC
in your own code. For instance, use in your own code. For instance, use :meth:`~datetime.datetime.fromtimestamp`
:meth:`~datetime.datetime.utcfromtimestamp` instead of and set the ``tz`` parameter to :data:`~django.utils.timezone.utc`.
:meth:`~datetime.datetime.fromtimestamp` -- and don't forget to set
``tzinfo`` to :data:`~django.utils.timezone.utc`.
Selecting the current time zone Selecting the current time zone
------------------------------- -------------------------------