Kaydet (Commit) 357d62d9 authored tarafından Jacob Kaplan-Moss's avatar Jacob Kaplan-Moss

Explained that timezone.now() always returns times in UTC.

The docs were ambiguous about the time zone for now(), leading people to
assume that it would be the current time zone rather that UTC.
üst 80b15113
...@@ -929,9 +929,21 @@ For a complete discussion on the usage of the following see the ...@@ -929,9 +929,21 @@ For a complete discussion on the usage of the following see the
.. function:: now() .. function:: now()
Returns an aware or naive :class:`~datetime.datetime` that represents the Returns a :class:`~datetime.datetime` that represents the
current point in time when :setting:`USE_TZ` is ``True`` or ``False`` current point in time. Exactly what's returned depends on the value of
respectively. :setting:`USE_TZ`:
* If :setting:`USE_TZ` is ``False``, this will be be a
:ref:`naive <naive_vs_aware_datetimes>` datetime (i.e. a datetime
without an associated timezone) that represents the current time
in the system's local timezone.
* If :setting:`USE_TZ` is ``True``, this will be an
:ref:`aware <naive_vs_aware_datetimes>` datetime representing the
current time in UTC. Note that :func:`now` will always return
times in UTC regardless of the value of :setting:`TIME_ZONE`;
you can use :func:`localtime` to convert to a time in the current
time zone.
.. function:: is_aware(value) .. function:: is_aware(value)
......
...@@ -54,6 +54,8 @@ FAQ <time-zones-faq>`. ...@@ -54,6 +54,8 @@ FAQ <time-zones-faq>`.
Concepts Concepts
======== ========
.. _naive_vs_aware_datetimes:
Naive and aware datetime objects Naive and aware datetime objects
-------------------------------- --------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment