[General] Pass a Date to Vapor

Hi everyone!

I would like to address some question about how to pass a Date data type to Vapor.

This is Error in Postman :

Screenshot 2020-01-11 at 10.06.54 PM

This is the Model :

Screenshot 2020-01-11 at 10.08.32 PM

Any help would be appreciate! :blush:

By default Vapor expects dates to be passed in ISO8601 format. So the quick option is to just use that.

Other options are to override the date format in the decoder or set it as String and transform it manually

1 Like

YYYY-MM-DD is the canonical ISO8601 date format: https://www.iso.org/iso-8601-date-and-time-format.html, and the OP is most definitely using that…

Sorry I should have been more precise - Swift expects a time as well as a date

1 Like