Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 408731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T17:43:13+00:00 2026-05-12T17:43:13+00:00

The documentation says: http://docs.djangoproject.com/en/dev/ref/settings/#time-zone Note that this is the time zone to which Django

  • 0

The documentation says:

http://docs.djangoproject.com/en/dev/ref/settings/#time-zone

Note that this is the time zone to
which Django will convert all
dates/times — not necessarily the
timezone of the server. For example,
one server may serve multiple
Django-powered sites, each with a
separate time-zone setting.
Normally, Django sets the
os.environ[‘TZ’] variable to the time
zone you specify in the TIME_ZONE
setting. Thus, all your views and
models will automatically operate in
the correct time zone.

I’ve read this several times and it’s not clear to me what’s going on with the TIME_ZONE setting.

Should I be managing UTC offsets if I want models with a date-time stamp to display to the users local-time zone?

For example on save use, datetime.datetime.utcnow() instead of datetime.datetime.now(), and in the view do something like:

display_datetime = model.date_time + datetime.timedelta(USER_UTC_OFFSET)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T17:43:14+00:00Added an answer on May 12, 2026 at 5:43 pm

    Much to my surprise, it does appear to.

    web81:~/webapps/dominicrodger2/dominicrodger$ python2.5 manage.py shell
    Python 2.5.4 (r254:67916, Aug  5 2009, 12:42:40)
    [GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    (InteractiveConsole)
    >>> import settings
    >>> settings.TIME_ZONE
    'Europe/London'
    >>> from datetime import datetime
    >>> datetime.now()
    datetime.datetime(2009, 10, 15, 6, 29, 58, 85662)
    >>> exit()
    web81:~/webapps/dominicrodger2/dominicrodger$ date
    Thu Oct 15 00:31:10 CDT 2009
    

    And yes, I did get distracted whilst writing this answer 🙂

    I use the TIME_ZONE setting so that my automatically added timestamps on object creation (using auto_now_add, which I believe is soon to be deprecated) show creation times in the timezone I set.

    If you want to convert those times into the timezones of your website visitors, you’ll need to do a bit more work, as per the example you gave. If you want to do lots of timezone conversion to display times in your website visitors’ timezones, then I’d strongly advise you to set your TIME_ZONE settings to store times in UTC, because it’ll make your life easier in the long run (you can just use UTC-offsets, rather than having to worry about daylight savings).

    If you’re interested, I believe the timezone is set from the TIME_ZONE setting here.

    Edit, per your comment that it doesn’t work on Windows, this is because of the following in the Django source:

    if hasattr(time, 'tzset'):
        # Move the time zone info into os.environ. See ticket #2315 for why
        # we don't do this unconditionally (breaks Windows).
        os.environ['TZ'] = self.TIME_ZONE
        time.tzset()
    

    Windows:

    C:\Documents and Settings\drodger>python
    ActivePython 2.6.1.1 (ActiveState Software Inc.) based on
    Python 2.6.1 (r261:67515, Dec  5 2008, 13:58:38) [MSC v.1500 32 bit (Intel)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import time
    >>> hasattr(time, 'tzset')
    False
    

    Linux:

    web81:~$ python2.5
    Python 2.5.4 (r254:67916, Aug  5 2009, 12:42:40)
    [GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import time
    >>> hasattr(time, 'tzset')
    True
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 231k
  • Answers 231k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Use the following function like this: Image('/path/to/original.image', '1/1', '150*', './thumb.jpg');… May 13, 2026 at 2:13 am
  • Editorial Team
    Editorial Team added an answer Check you database schema to see if the field (referenced… May 13, 2026 at 2:13 am
  • Editorial Team
    Editorial Team added an answer I figured out the problem - there was a session… May 13, 2026 at 2:13 am

Related Questions

Where should DATETIME_FORMAT be placed for it to have effect on the display of
I have been trying all afternoon to get the jQuery Sifr Plugin ( http://jquery.thewikies.com/sifr/
I'm reading about the CallContext class ( http://msdn.microsoft.com/en-us/library/system.runtime.remoting.messaging.callcontext.aspx ). The documentation says something about
I'm using SQLite from a C# program using SQLite.net ( http://sqlite.phxsoftware.com ). By default

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.