summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2014-07-31 12:54:11 -0400
committerTim Graham <timograham@gmail.com>2014-07-31 12:57:50 -0400
commit42bb047d33afc2bc6205a2d9ffc24aeec626ce7f (patch)
treeffa5b0c75ea8d1fc4f6bab3298c9cad1ab35747d /docs
parent063e7e56bcd34d76e9072ebfa3b9f1d9679dc6e9 (diff)
[1.7.x] Updated timezone docs to use timezone.now()
Thanks James Cleveland for the report and Aymeric for suggesting the solution. Backport of da59902250 from master
Diffstat (limited to 'docs')
-rw-r--r--docs/topics/i18n/timezones.txt19
1 files changed, 6 insertions, 13 deletions
diff --git a/docs/topics/i18n/timezones.txt b/docs/topics/i18n/timezones.txt
index 6c6f12eb4b..ddb161de2b 100644
--- a/docs/topics/i18n/timezones.txt
+++ b/docs/topics/i18n/timezones.txt
@@ -78,20 +78,13 @@ the current time, you would write::
now = datetime.datetime.now()
-When time zone support is enabled, Django uses time-zone-aware datetime
-objects. If your code creates datetime objects, they should be aware too. In
-this mode, the example above becomes::
+When time zone support is enabled (:setting:`USE_TZ=True <USE_TZ>`), Django uses
+time-zone-aware datetime objects. If your code creates datetime objects, they
+should be aware too. In this mode, the example above becomes::
- import datetime
- from django.utils.timezone import utc
-
- now = datetime.datetime.utcnow().replace(tzinfo=utc)
-
-.. note::
+ from django.utils import timezone
- :mod:`django.utils.timezone` provides a
- :func:`~django.utils.timezone.now()` function that returns a naive or
- aware datetime object according to the value of :setting:`USE_TZ`.
+ now = timezone.now()
.. warning::
@@ -554,7 +547,7 @@ Troubleshooting
>>> import datetime
>>> from django.utils import timezone
>>> naive = datetime.datetime.utcnow()
- >>> aware = naive.replace(tzinfo=timezone.utc)
+ >>> aware = timezone.now()
>>> naive == aware
Traceback (most recent call last):
...