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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:02:00+00:00 2026-06-02T11:02:00+00:00

My cloud server logs time in this format: [17/Dec/2011:09:48:49 -0600] To read it into

  • 0

My cloud server logs time in this format:

[17/Dec/2011:09:48:49 -0600]

To read it into Python variables, I can say:

>>>str = '17/Dec/2011:09:48:49 -0600'
>>>import time
>>>print  time.strptime(str,"%d/%b/%Y:%H:%M:%S -0600")

Result:

time.struct_time(tm_year=2011, tm-mon=12, tm=mday=17, tm_hour=9, tm_min=48, tm_sec=49, tm_wday=5, tm_yday=351, tm_isdst=-1)

or I can try

>>>mytime = time.strptime(str,"%d/%b/%Y:%H:%M:%S -0600")
>>>print mytime.tm_hour

Result:

9

What does the -0600 do? I expected it to adjust the hour value in the date time object? Is there a wildcard to use instead of hard-coding the -0600?

  • 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-02T11:02:04+00:00Added an answer on June 2, 2026 at 11:02 am

    The -0600 is the offset from Greenwich Mean Time (GMT). As another SO question already says, time.strptime cannot read timezone offsets, though datetime.strftime can generate them.

    As explained at the start of the datetime module’s documentation, there are two ways of approaching “time” in python, naive or aware. When all you care about is time inside your system, dealing with naive time/datetime objects is fine (in which case you can strip out the offset as alan suggested). When you need to compare the values inside your system with the real world’s notion of time, you have to start dealing with that offset.

    The easy way to deal with this is just to use python-dateutil. It has a parse function that will do its best to fuzzily match the date string you pass in to multiple formats and return a workable datetime instance that represents its best guess as to what you meant.

    >>> from dateutil.parser import parse
    >>> parse('17/Dec/2011:09:48:49 -0600', fuzzy=True)
    datetime.datetime(2011, 12, 17, 9, 48, 49, tzinfo=tzoffset(None, -21600))
    

    Normally, having software give its “best guess” is a Bad Thing. In this case, it seems justified if your input formats are stable. Dealing with time in software development is hard, just go shopping.

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

Sidebar

Related Questions

Cloud server begin generate big disk read/write operation. I want find some script who
Is there a Tag Cloud server control for ASP.NET that can satisfy theese requirements:
ohk i am facing this very weird problem . i have a cloud server
I've read every question and answer on this topic I can find on this
Ignoring the model name, it appears this cloud server has 4 single core processors
Very simple question, is there any cloud server enviroments avaliable these days for us
I just installed rvm + rails 3+ on centos 6.0 at Rackspace cloud server.
I have mysql DB on cloud linux server. I am able to connect db
I have a server running on the Amazon cloud running ColdFusion 9.0.1. on Windows
I am deploying Ruby On Rails apps on an Amazon EC2 cloud server. 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.