Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Datetime format in flask marshmallow schema

I want to apply a custom DateTime format for the data retrieved from model using the Schema in flask marshmallow.

Currently using the schema like:

class ScheduleListSchema(ma.Schema):
    class Meta:
        fields = ('id', 'start_time', 'end_time')

In this start_time in format of 2018-12-05T03:00:00+00:00

So I want to create a custom format for the start_time value in schema.

like image 581
Shijo Rose Avatar asked Nov 20 '25 10:11

Shijo Rose


1 Answers

You can use the code like this:

start_time = fields.fields.DateTime(format='%Y-%m-%dT%H:%M:%S%z')

like image 103
Shijo Rose Avatar answered Nov 22 '25 01:11

Shijo Rose



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!