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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:04:42+00:00 2026-06-05T11:04:42+00:00

I have a datetime string in the form of a string as: 2011-10-23T08:00:00-07:00 How

  • 0

I have a datetime string in the form of a string as:

2011-10-23T08:00:00-07:00

How do i parse this string as the datetime object.

I did the following reading the documentation:

date = datetime.strptime(data[4],"%Y-%m-%d%Z")

BUt I get the error

  ValueError: time data '2011-10-23T08:00:00-07:00' does not match format '%Y-%m-%d%Z'

which is very clear.

But I am not sure how to read this format.

Any suggestions.
Thanks

Edit: Also, I must add, all I care about is the date part

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

    Standard datetime.datetime.strptime has problems with timezone definitions. Use dateutil.parser

    >>> from dateutil import parser
    >>> parser.parse("2011-10-23T08:00:00-07:00")
    datetime.datetime(2011, 10, 23, 8, 0, tzinfo=tzoffset(None, -25200))
    

    If you care about the date part only, you can try it without dateutil.parser:

    >>> from datetime import datetime
    >>> datetime.strptime(data[4].partition('T')[0], '%Y-%m-%d').date()
    datetime.date(2011, 10, 23)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this object: class a { public string Application; public DateTime From, To;
I have the following method: public object[] GetEventsByUser(DateTime start, DateTime end, string fullUrl) The
I have the following wonderfully unreliable statement: string LastsuccessfuldownloadDateTime = 04.07.2009 19:21:36 DateTime myDate
I have a service that give me a date time string in the following
I have a source where dates comes in this string form: Sat Sep 22
I have a date in string form and input timeformat(ex: hh:mm tt). I want
I have a date time string that I don't know how to parse it
I have a datetime string in the form of a string as: 20120808111051 How
I have a textbox on my AJAX form which contains date-time formatted string in
So I have a flashobject which I need to pass a formatted DateTime string

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.