Skip to content

Commit ecdd091

Browse files
committed
Updated time zone FAQ with timezone.localize.
1 parent 57102ce commit ecdd091

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

docs/topics/i18n/timezones.txt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ Usage
664664
documentation of pytz contains `more examples`_. You should review it
665665
before attempting to manipulate aware datetimes.
666666

667-
2. **How can I obtain the current time in the local time zone?**
667+
2. **How can I obtain the local time in the current time zone?**
668668

669669
Well, the first question is, do you really need to?
670670

@@ -678,15 +678,14 @@ Usage
678678
the datetime in UTC returned by :func:`django.utils.timezone.now` will be
679679
sufficient.
680680

681-
For the sake of completeness, though, if you really wanted the current time
682-
in the local time zone, here's how you would obtain it::
681+
For the sake of completeness, though, if you really want the local time
682+
in the current time zone, here's how you can obtain it::
683683

684-
>>> import datetime
685684
>>> from django.utils import timezone
686-
>>> datetime.datetime.now(tz=timezone.get_default_timezone())
685+
>>> timezone.localtime(timezone.now())
687686
datetime.datetime(2012, 3, 3, 20, 10, 53, 873365, tzinfo=<DstTzInfo 'Europe/Paris' CET+1:00:00 STD>)
688687

689-
In this example, pytz_ is installed and :setting:`TIME_ZONE` is
688+
In this example, pytz_ is installed and the current time zone is
690689
``"Europe/Paris"``.
691690

692691
3. **How can I see all available time zones?**

0 commit comments

Comments
 (0)