title: Converting time format with strftime and strptime
body: <p>I have a csv file contains three column. First is the date in the format of <code>1/3/2018</code>. Second is time <code>10:00:00 AM</code>. Third is the temperature. Now I want to use <code>strftime()</code> to convert the <code>datetime</code> object to the format <code>"YYYY/MM/DD HH:MM:SS AM"</code> and store a list of time that the temperature is over 80.</p>
  
  <pre class="lang-py prettyprint-override"><code>import csv
  from datetime import datetime
  
  with open("temp.csv") as csvfile, open('output.csv','w') as output_file: #types of file opened "wb": binary file
      csv_reader = csv.reader(csvfile, delimiter=",")
      csv_output = csv.writer(output_file)
      next(csv_reader, None) #skip header
      rows = [row for row in csv_reader if row[2] &gt;= '80.0'] #if condition
      output = []
      for row in rows:
          date = datetime.strptime(row[0], '%m/%d/%Y') # strp is a function under datetime. convert a string to a datetime object
          time = datetime.strptime(row[1], '%H:%M:%S %p')
          output.append([date, time])
          date_str = date.strftime('%m/%d/%Y') #strftime: convert datetime object into a string
          time_str = time.strftime('%H:%M:%S %p')
          csv_output.writerow([date_str,time_str])
  
  print(output)
  </code></pre>
  
  <p>The current result is:</p>
  
  <pre class="lang-none prettyprint-override"><code>[[datetime.datetime(2018, 1, 2, 0, 0), datetime.datetime(1900, 1, 1, 5, 0)], [datetime.datetime(2018, 1, 2, 0, 0)...
  </code></pre>
  
  <p>I expect the result to be:</p>
  
  <pre class="lang-none prettyprint-override"><code>[1/2/2018 10:00:00 ], [1/2/2018 11:00:00]....
  </code></pre>