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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:13:25+00:00 2026-05-18T02:13:25+00:00

I am having the hardest time trying to get the current time in EDT

  • 0

I am having the hardest time trying to get the current time in EDT timezone.

print datetime.time(datetime.now()).strftime("%H%M%S")

datetime.now([tz]) has an optional tz argument, but it has to be of type datetime.tzinfo… I have not ben able to figure out how to define a tzinfo object for Eastern timezone… Seems like it should be pretty simple, but I cant figure it out without importing an additional library.

  • 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-18T02:13:25+00:00Added an answer on May 18, 2026 at 2:13 am

    I am not very conversent about the EDT time zone but this example should serve your purpose.

    import datetime
    

    datetime.datetime.now must be passed the time zone info which should be of type datetime.tzinfo. Here is a class that implements that with some of the required functions. I am providing no day light saving details here as this is an example.

    class EST(datetime.tzinfo):
        def utcoffset(self, dt):
          return datetime.timedelta(hours=-5)
    
        def dst(self, dt):
            return datetime.timedelta(0)
    

    Now you could use this to get the info with time zone correctness:

    print datetime.datetime.now(EST()) 
    

    Output:

    2010-11-01 13:44:20.231259-05:00 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having spent some time working on data warehousing, I have created both ETL (extract
Having the following code, how can I have get receive a map, and return
For example if I was given the string 01/01/1980. How could I then get
Having recently upgraded to TFS2010 I am having a problem building web applications. In
Having some trouble getting a JSON feed to load from my site. I'm starting
Having studied the switch documentation and discovering it can only switch on integral types
Having successfully got a WCF service and client to talk to one another using
having trouble with a double component uipicker, everything shows up and it fills with
having a bit of trouble visualizing how a join should look for a particular
I am developing a drop down menu that uses HTML optgroups for group names

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.