title: "TypeError: must be string, not datetime.datetime" in Jinja2 template when using strftime
body: <p>I'm trying to format dates generated with <code>datetime.datetime.utcnow()</code> (using this because it's the equivalent of <code>ISODate()</code> in MongoDB which is the database my app uses) in my Flask application but Jinja2 won't render them.</p>
  
  <p>I have the following function in my app:</p>
  
  <pre><code>def format_isodate(timestamp):
      """Format a ISODate time stamp for display."""
      date = datetime.datetime.strptime(timestamp, "%Y-%m-%d %H:%M:%S.%f")
      return date.strftime('%Y-%m-%d @ %H:%M:%S')
  </code></pre>
  
  <p>The dates look like this: </p>
  
  <pre><code>"2013-07-04 20:06:05.088000"
  </code></pre>
  
  <p>And I have the following filter:</p>
  
  <pre><code>app.jinja_env.filters['isodateformat'] = format_isodate
  </code></pre>
  
  <p>But when I try to format the timestamp in templates:</p>
  
  <pre><code>{{ change.submit_date|isodateformat }}
  </code></pre>
  
  <p>I get this error:</p>
  
  <blockquote>
    <p>"TypeError: must be string, not datetime.datetime"</p>
  </blockquote>
  
  <p>I don't understand why I am getting this error. Doesn't <code>strftime()</code> convert dates to string?</p>