Date format on API call

Hello everyone,

I wanted to changed the format of the date, although now on my model I see 21/07/2022 instead of 07/21/2022, which is correct:
image

then …when I get the response on the frontend I am getting 2022 - 05 -21

So I wanted to know if this supposed to be like that, and the configuration only affects the backend format but not the response?

Thank you in advance for your help : )

Hello @maria.arce

As you said, that option only affects how you view the date on the dashboard, not the API response.
The API response is kept always the same to guarantee consistency across responses.

You can use the response to create a Date object on JS, that allows you to access several methods for date conversion or formatting, as such:

date = new Date('2013-08-03T02:00:00Z');
year = date.getFullYear();
month = date.getMonth();
dt = date.getDate();

Hi @m.finamor , thank you for the response. And as I thought… in that case I am sharing my approach in case some else is looking for something like this:

 myDate.split("-").reverse().join("/");

where “myDate” is the date coming from the API response, and at the end you get dd/mm/yyyy hope this helps someone.

Cheers

1 Like