title: Python datetime to string without microsecond component
body: <p>I'm adding UTC time strings to Bitbucket API responses that currently only contain Amsterdam (!) time strings. For consistency with the UTC time strings returned elsewhere, the desired format is <code>2011-11-03 11:07:04</code> (followed by <code>+00:00</code>, but that's not germane).</p>
  
  <p>What's the best way to create such a string (<em>without</em> a microsecond component) from a <code>datetime</code> instance <em>with</em> a microsecond component?</p>
  
  <pre><code>&gt;&gt;&gt; import datetime
  &gt;&gt;&gt; print unicode(datetime.datetime.now())
  2011-11-03 11:13:39.278026
  </code></pre>
  
  <p>I'll add the best option that's occurred to me as a possible answer, but there may well be a more elegant solution.</p>
  
  <p><strong>Edit:</strong> I should mention that I'm not <em>actually</em> printing the current time – I used <code>datetime.now</code> to provide a quick example. So the solution should not assume that any <code>datetime</code> instances it receives will include microsecond components.</p>