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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T11:22:06+00:00 2026-05-19T11:22:06+00:00

In Python, I want a Python program to be able to determine the current

  • 0

In Python, I want a Python program to be able to determine the current date and time in NYC . Is that practical? While datetime.datetime.now() can tell me the local time, and datetime.utcnow() can tell me the UTC (GMT). However just looking at the difference will not help me as DST changes.

I try things like “dt=datetime.now() ” and “dt.timetuple()”
I get tm_isdst=-1 even if I change the computer date.

I change my computer clock from a January date to a July date. I still get tm_isdst=-1

Why not use pytz? I want the users to not have to go thru the step of downloading an extra 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-19T11:22:07+00:00Added an answer on May 19, 2026 at 11:22 am

    I suspect some sort of problems in your use of the datetime, time, etc. modules, but without knowing more, not much help can be provided.

    The following suggestion has some definite drawbacks, and I really recommend more pursuit to solving the problems with datetime, etc. However, if you’re sure to have a web connection and need to get something done fast, you could query USNO time with something like:

    import urllib
    f = urllib.urlopen("http://tycho.usno.navy.mil/cgi-bin/timer.pl")
    time_page = f.readlines()
    for line in time_page:
        if line.find("Eastern Time") != -1:
            ny_time = line[4:24]
            break
    print ny_time
    

    The output looks like:

    Jan. 19, 05:18:04 PM

    This makes use of the fact that NYC is in the Eastern Time zone. Also, it assumes the USNO server is available to your user. Furthermore, it has assumptions about the format of the content returned. I don’t know if/how frequently that format changes. Also, if this is going to be used a lot, please find another server, as you don’t want to sink the USNO server! (Pun not originally intended, but recognized and kept. :-).

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

Sidebar

Related Questions

I want to parse an Apache access.log file with a python program in a
I want to create a very simple HTML/AJAX based GUI for a Python program.
Using Python I want to be able to draw text at different angles using
I want to start using Python for small projects but the fact that a
I want to write a function in Python that returns different fixed values based
I want to run javascript/Python/Ruby inside my application. I have an application that creates
I want to try out SICP with Python. Can any one point to materials
I want to be able to run my Python project from the command line.
I want to use Decimal class in my Python program for doing financial calculations.
I'm running Python 2.4 in a game engine and I want to be able

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.