title: How to remove unconverted data from a Python datetime object
body: <p>I have a database of mostly correct datetimes but a few are broke like so: <code>Sat Dec 22 12:34:08 PST 20102015</code></p>
  
  <p>Without the invalid year, this was working for me:</p>
  
  <pre><code>end_date = soup('tr')[4].contents[1].renderContents()
  end_date = time.strptime(end_date,"%a %b %d %H:%M:%S %Z %Y")
  end_date = datetime.fromtimestamp(time.mktime(end_date))
  </code></pre>
  
  <p>But once I hit an object with a invalid year I get <code>ValueError: unconverted data remains: 2</code>, which is great but im not sure how best to strip the bad characters out of the year. They range from 2 to 6 <code>unconverted characters</code>.</p>
  
  <p>Any pointers? I would just slice <code>end_date</code> but im hoping there is a datetime-safe strategy.</p>