title: Detecting date format and converting them to MM-DD-YYYY using Python3
body: <p>I am trying to convert the date formats and make them uniform throughout the document using Python 3.6.<br>
  Here is the sample of the dates in my document:(There can be other formats as the document is large.)</p>
  
  <pre><code>9/21/1989
  19640430
  6/27/1980
  5/11/1987
  Mar 12 1951
  2 aug 2015
  </code></pre>
  
  <p>I have checked the <code>datetime</code> lbrary. But could not understand hoow to detect and change the format of the dates automatically. Here is what I have checked till now:  </p>
  
  <pre><code>&gt;&gt;&gt; from datetime import datetime
  &gt;&gt;&gt; oldformat = '20140716'
  &gt;&gt;&gt; datetimeobject = datetime.strptime(oldformat,'%Y%m%d')
  &gt;&gt;&gt; newformat = datetimeobject.strftime('%m-%d-%Y')
  &gt;&gt;&gt; print (newformat)
  07-16-2014
  </code></pre>
  
  <p>But I am not getting how I can make the program detect the date patterns automatically and convert them to one single uniform pattern of dates as <code>mm/dd/yyyy</code><br>
  Kindly, suggest what I need to do, so as to achieve my goal using Python 3.6.</p>