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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:23:36+00:00 2026-05-23T10:23:36+00:00

I have a meeting model with a start time column: class Meeting(mode.Model): name =

  • 0

I have a meeting model with a start time column:

class Meeting(mode.Model):
    name = models.CharField(max_length=100)
    start = models.DateTimeField()

My time zone is set to TIME_ZONE = 'America/Toronto'

I’m currently entering the EDT value of the time. In my template, I want to display both the EDT and PDT values, for example:

| Name          | Start        |
| First Meeting | 10:00 AM PDT |
|               |  1:00 PM EDT |

Is it currently possible in Django to display two different timezone values from a single entry?

  • 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-23T10:23:36+00:00Added an answer on May 23, 2026 at 10:23 am

    Depends how you want it to render. I’d make a templatetag, and then you could put things like {{ start_time|pdt_edt }}. The benefit of this method over defining functions in the class objects is that you can reuse the filter for other datetimes that need to be printed in both formats. (E.g., if your meeting had an end time; or another object had a time that you’d like to list in both formats).

    I’d suggest starting with pytz to handle (install easy_install.py pytz).

    Basically make a sub-directory of your app called templatetags/ put in an __init__.py and another file call it something say time_zone_display.py for your template tag. (Basic procedure

    In your template include

    {% load time_zone_display %}
    ...  
    {{ start_time|pdt_edt }}
    

    And in time_zone_display.py something like

    from django import template
    from django.utils.safestring import mark_safe
    from datetime import datetime, time
    
    register = template.Library()
    @register.filter
    def pdt_edt(some_date):
        if type(some_date) not in (datetime, time):
            return "Template ERROR: Not a datetime" 
        else:
            your_time = pytz.timezone(settings.TIME_ZONE)
            d = your_time.localize(some_date)
            pdt = pytz.timezone('US/Pacific')
            edt = pytz.timezone('US/Eastern')
            d_pdt = d.astimezone(pdt).strftime('%I:%M %p %Z')            
            d_edt = d.astimezone(edt).strftime('%I:%M %p %Z')
            return mark_safe("%s<br />%s" % (d_pdt, d_edt))
    

    You could also simplify the template if you know that your settings.TIME_ZONE will always be a fixed offset (3 hours) from pacific time, so then you could just do something like:

    from django import template
    from django.utils.safestring import mark_safe
    from datetime import datetime, time, timedelta
    
    register = template.Library()
    @register.filter
    def pdt_edt(some_date):
        if type(some_date) not in (datetime, time):
            return "Template ERROR: Not a datetime" 
        else:
            d_edt = some_date.strftime("%H:%M %p EDT")
            d_pdt = (some_date - timedelta(0,3*60*60)).strftime("%H:%M %p PDT")
            return mark_safe("%s<br />%s" % (d_pdt, d_edt))
    

    (Though EDT/PDT are only the correct abbreviations during daylight’s savings time; so the first method is better thought it requires installing pytz).


    EDIT: the rare case when Eastern time and pacific time are not off by three hours, but pytz will handle correctly.

    >>> from datetime import datetime
    >>> import pytz
    >>> ptz = pytz.timezone('US/Pacific')
    >>> etz = pytz.timezone('US/Eastern')
    >>> d = datetime(2011,3,13, 3, 30) # 3:30 am on March 13th,2011 when daylights savings started this year
    >>> print d.astimezone(etz).strftime('%m/%d/%Y %I:%M %p %z')
    03/13/2011 03:30 AM EDT
    >>> print d.astimezone(ptz).strftime('%m/%d/%Y %I:%M %p %z')
    03/12/2011 11:30 PM PST
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table which stores in each row a meeting with start date/time
I have an ASP.NET MVC Page with a button called Start Live Meeting. When
I have a set of Meeting rooms and meetings in that having start date
I have a file of the following format Summary:meeting Description:None DateStart:20100629T110000 DateEnd:20100629T120000 Time:20100805T084547Z Summary:meeting
I have a Meeting model, with multiple Participants in different roles (say, Tutor and
i'm using djangorestframework. the models one meeting could have many participates. So i tried
I have the following models: class Mark < ActiveRecord::Base validates_presence_of :user validates_presence_of :page belongs_to
I have two associated models (meetings and departments). A meeting has exactly one department,
I have an issue with meeting XHTML Strict requirements for a class assignment. The
I have a data validation class that checks whether the start date of 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.