title: Custom date format for flask_restful fields.DateTime for marshal_with
body: <p>I am using flask_restful's fields and marshal_with to serialize my APIs output data. But I am having problems with my date format.</p>
  <p>I am storing the date as an SQLAlchemy DateTime type, for example, my date is stored as 2020-01-01 00:00:00.000000 in the database.</p>
  <p>I want the date to be serialized in the format yyyy-mm-dd, for example, 2020-01-01 but when I use fields.DateTime(dt_format='iso8601') from flask_restful I get the serialized output as &quot;date&quot;: &quot;2020-01-01T00:00:00&quot;.</p>
  <p>Below are some code snippets that might help</p>
  <pre><code>class Product(db.Model):
      id = db.Column(db.Integer, primary_key=True)
      date = db.Column(db.DateTime)
  
  resource_fields = {
      'id': fields.Integer,
      'date': fields.DateTime(dt_format='iso8601')
  
  class ProductList(Resource):
      @marshal_with(resource_fields)
      def get(self):
          data = Product.query.all()
          return data, 200
  
  
  api.add_resource(ProductList, &quot;/home&quot;)
  </code></pre>
  <p>Serialized output</p>
  <pre><code>[
      {
          &quot;id&quot;: 1,
          &quot;date&quot;: &quot;2020-01-01T00:00:00&quot;
      }
  }
  </code></pre>
  <p>How do I make a custom serializer for my date in flask_restful to format it as yyyy-mm-dd without the time? Or at least remove T00:00:00 and present the date as 2020-01-01.</p>
  <p>Thank you</p>