Python Format Date issue
<p>Something which I thought would be simple has become such a struggle.
I'm trying to format a datetime object.</p>

<pre><code>From this 2016-06-17 09:56:53.289000+00:00 to 2016-06-17 09:56:53
</code></pre>

<p>This code I tried doesn't make any changes to the output. It skips right past it.</p>

<pre><code>if type(field) is models.DateField:
   if old_value != None:
      old_value = old_value.strftime('%Y-%m-%d %H:%M:%S')[:-3]
   if new_value != None:
      new_value = new_value.strftime('%Y-%m-%d %H:%M:%S')[:-3]
</code></pre>

<p>Then I tried the following</p>

<pre><code> if isinstance(new_value, datetime.datetime):
    new_value = new_value.utcnow().strftime('%Y-%m-%d %H:%M:%S')[:-3]
 if isinstance(old_value, datetime.datetime):
    old_value = old_value.utcnow().strftime('%Y-%m-%d %H:%M:%S')[:-3]
</code></pre>

<p>However it removes any trace of the values of both new_value and old_value and displays nothing. Which is confusing me so much!</p>

<p>The end part of my code is as follows which displays the date:</p>

<pre><code> if new_value != old_value:
    print "%s does not match" % key
    changes[key] = "Field %s %s updated to %s&lt;br/&gt;" % (key, old_value, new_value)
</code></pre>

<p>If anyone could point me in the right direction that would be great.</p>