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

  • SEARCH
  • Home
  • 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 9246967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:37:02+00:00 2026-06-18T09:37:02+00:00

Need a ListBox/Dropdown with pytz common_timezones name each difference for UTC. <select style=cursor:pointer; min-width:

  • 0

Need a ListBox/Dropdown with pytz common_timezones name each difference for UTC.

<select style="cursor:pointer; min-width: 300px;" name="timezone">
    {% for tz in timezones %}
        <option value="{{ tz }}"{% if tz == TIME_ZONE %} selected="selected"{% endif %}>{{ tz }}</option>
    {% endfor %}
</select>

I’m feeding that list with:
‘timezones’: pytz.common_timezones, ‘TIME_ZONE’: request.session[‘django_timezone’]
on render to response…

but I’m getting only a list of names.. I needed a list of names the difference of each time zone for UTC..

example:

America/XYZ UTC-xxxx/UTC-xxxx+1

Europe/XPTO UTC+xxxx

Edited: I would be happy getting the present known offsets for each timezone like showed here http://www.timeanddate.com/worldclock/) in this moment (this instant) and if possible with one/two last years spawn (the possibilities like: http://www.timeanddate.com/library/abbreviations/timezones/).

Thanks in advance for any help given!

  • 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-06-18T09:37:03+00:00Added an answer on June 18, 2026 at 9:37 am

    I came to this one:

    def get_timezones_with_gmt_diff(timezone_string_list = None):
        """
        Converts a datetime object into string.
        """
        if timezone_string_list:
            timezone_list = timezone_string_list
        else:
            timezone_list = pytz.common_timezones
    
        datetime1 = datetime.strptime("10-07-%s 00:00:00" % datetime.utcnow().year, "%d-%m-%Y %H:%M:%S")
        datetime2 = datetime.strptime("10-12-%s 00:00:00" % datetime.utcnow().year, "%d-%m-%Y %H:%M:%S")
    
        result_dict = {}
        for time_zone in timezone_list:
            result_dict[time_zone] = [Date.timedelta_in_seconds(pytz.timezone(time_zone).localize(datetime1).tzinfo._utcoffset)/3600,
                                      Date.timedelta_in_seconds(pytz.timezone(time_zone).localize(datetime2).tzinfo._utcoffset)/3600,
                                      time_zone.replace("/", " - ").replace("_", " "),
                                      Date.timedelta_in_seconds(pytz.timezone(time_zone).localize(datetime1).tzinfo._utcoffset)/3600 !=
                                      Date.timedelta_in_seconds(pytz.timezone(time_zone).localize(datetime2).tzinfo._utcoffset)/3600]
    
        sorted_result_dict = OrderedDict(sorted(result_dict.items(), key=lambda t: t[1][2]))
        return sorted_result_dict
    
    def get_timezones_for_listbox(time_zones_dict):
        list = []
        for time_zone_tuple in time_zones_dict:
            # Has different DST/Summer times:
            if time_zones_dict[time_zone_tuple][3]:
                new_item = "%s      UCT %s/%s" % (str(time_zones_dict[time_zone_tuple][2]), str(time_zones_dict[time_zone_tuple][0]), str(time_zones_dict[time_zone_tuple][1]))
            # Does not change datetime:
            else:
                new_item = "%s      UCT %s" % (str(time_zones_dict[time_zone_tuple][2]), str(time_zones_dict[time_zone_tuple][0]))
            list.append(new_item)
        return list
    
    def timedelta_in_seconds(duration):
        days, seconds = duration.days, duration.seconds
        return days * 24 * 60 * 60 + seconds
    

    of course I will further manipulate these two methods in order to accomplish the desired output from my input context.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a ListBox which will contain several options. I need checkboxes exactly(style), not
I need to select all items in a ListBox when a CheckBox is clicked.
I need to make the ListBox expand to fit the width it has available.
I need to programatically select a subset of ListBoxItems in a ListBox ( SelectedMode=Multiple
I have a sorted listbox and need to display each item's row number. In
I need to be able to manually select ListBox items in Windows Phone 7.
While making AutoHotkey-script I encountered the following problem. I need navigate listbox (one position
I have a ListBox and I need to repeat the styles to be the
I have a custom ItemTemplate for a ListBox and I need to bind a
I have a ListBox with databinding. I need to fire an event when a

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.