0
I have a class:
public class Filtros{
public DateTime DataInicial { get; set; }
public DateTime DataFinal { get; set; }
//outros campos...
}
I have a C# API that takes the class:
[HttpPost("ObterProvisoes")]
public JsonResult ObterProvisoes(Filtros filtros)
{
//recebe mm/dd/yyyy
}
Then send the object Filters filled:
var filtros = {
DataInicial: self.DataInicial, // dd/mm/yyyy
DataFinal: self.DataFinal // dd/mm/yyyy
}
$.post("/api/RelatorioFinanceiro/ObterProvisoes", filtros, function () {
}).done(function (response) {
//funcoes
});
When I send the completed object the date is in the format dd/mm/yyyy, but the api receives as mm/dd/yyyy. Is there any way to configure the API or project (Asp.net core 1.1) not to change the date? Or inform that the date format is dd/mm/yyyy in the api?
OBS: I don’t want to use functions in javascript that convert the date, because I would have to do this every time I had a date in the project, I think it’s wrong, I want to solve it at once, that has effect on all.
Related: Soen.
– Francisco
@Aesir, need to include what you have already done/ tried to do. Put the source code, etc. Take a look at [Ask]
– Rodolpho Sa
I’m complementing, I already update.
– Aesir
format your date for it to go in the api with its format
– Bruno H.
Probably the API wasn’t you who made it and you just consume it, right? In this case, the API probably uses American format for dates and you can’t change that. My advice is to format the date before sending to the mm/dd/yyyy format.
– perozzo
@Brunoh. I don’t want to change the javascript side because I want a global solution.
– Aesir
@Perozzo The API is mine, I want a way to configure it to receive the dates in BR format.
– Aesir
@Brunoh. I need a way to set this up, because if the informed day is greater than 12 it gets as 1 in the API, as there is no month 13 for example, not running the conversion on the API side
– Aesir