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 6564067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:55:14+00:00 2026-05-25T13:55:14+00:00

I have a python application that is sending email reminders to users in different

  • 0

I have a python application that is sending email reminders to users in different timezones. The start time is set to a given date and time, and the reminder may be set to some number of minutes before the start time.

The previous developer did not take into account the user’s timezone, so reminders were always being sent based on the server’s time.

Using the pytz documentation, I initially tried using UTC for everything, and while this worked in development, the reminders were still off in production. At first, I assumed that this was a problem with NTP on the server, but this was not the case.

I wanted to confirm that development and production were indeed behaving differently, so I created a simple script for testing between the two:

server_time = datetime.datetime.utcnow()
print "Server Time:", server_time

user_timezone = pytz.timezone('America/Montevideo')
print "User Timezone:", user_timezone

user_offset = user_timezone.utcoffset(server_time)
print "Offset:", user_offset

user_datetime = server_time + user_offset
print "User Time:", user_datetime

The result in development (correct):

Server Time: 2011-09-07 16:53:00.711334
User Timezone: America/Montevideo
Offset: -1 day, 21:00:00
User Time: 2011-09-07 13:53:00.71133

The result in production (incorrect):

Server Time: 2011-09-07 16:53:01.767143
User Timezone: America/Montevideo
Offset: -1 day, 20:15:00
User Time: 2011-09-07 13:08:01.767143

So it looks like pytz is simply giving the wrong offset. Note that it doesn’t matter if I use a different timezone; every one I’ve tried gives the wrong offset.

As for the difference in environments, both are Ubuntu boxes, but production is running Python 2.5.2 and development is 2.6.2.

There aren’t very many bugs reported for pytz, and I haven’t found a reason for different offsets in any of my searching.

So is this a problem with pytz data on my production server? A pytz bug? Or a problem with my understanding of pytz? What am I missing?

  • 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-25T13:55:15+00:00Added an answer on May 25, 2026 at 1:55 pm

    Using pytz 2010 version

    $ python test.py 
    Server Time: 2011-09-16 00:20:49.479426
    User Timezone: America/Montevideo
    **Offset: -1 day, 20:15:00** wrong!
    User Time: 2011-09-15 20:35:49.479426-03:00
    

    Using pytz 2011 version

    $ python test.py 
    Server Time: 2011-09-16 00:36:54.764812
    User Timezone: America/Montevideo
    **Offset: -1 day, 21:00:00** great!
    User Time: 2011-09-15 21:36:54.764812
    

    Look at the pytz.VERSION and make sure you are using at least 2011h

    >>> import pytz
    >>> pytz.VERSION
    '2011h'
    

    If you have 2010, remove and replace:

    >>> pytz.__file__
    /usr/lib/python2.6/dist-packages/pytz/__init__.pyc
    
    $ sudo rm -r /usr/lib/python2.6/dist-packages/pytz*
    $ sudo pip install pytz == 2011h
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a python application that relies on a file that is downloaded by
Long story short, I have a substantial Python application that, among other things, does
We have a Linux application that makes use of OpenSSL's Python bindings and I
I want to run javascript/Python/Ruby inside my application. I have an application that creates
I have an application that is sending a JSON object (formatted with Prototype) to
I have a very simple mod_wsgi python application that tries to write to a
I have a currently running PHP application that I want to add real-time feed
I have a Python application that, to be brief, receives data from a remote
I have a python application that needs to interact with an open MsWord document
I have a Python application (with GUI, using PyQt4) that gets spawned by the

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.