1

According to the documentation, this is how the datetime type is returned:

A Python datetime.datetime. In requests and responses will be represented as a str in ISO 8601 format, like: 2008-09-15T15:53:00+05:00

I'm having difficulties dealing with that date format on my front end. Is it possible to force FastAPI to return a DateTime so it only shows date + hours/minutes/seconds?

Siqueler
  • 35
  • 1
  • 5
  • 2
    As fastapi uses pydantic under the hood, you might want to have a look at this https://stackoverflow.com/questions/66548586/how-to-change-date-format-in-pydantic – Simon Hawe Dec 08 '22 at 09:37
  • its allways just `date_string[:-5]` and yeah you could just return a string instead of a datetime object ... – Joran Beasley Dec 08 '22 at 09:38

0 Answers0