0
I’m having a very boring problem, I’m picking one up DataDeCadastro
of the server on DateTime
when the date well it is in the United States version ("dd/MM/yyyy")
I use the .ToString()
to format the way I want.
I have a form of editing in which the person can change the registration date, but when I try to send to the server it reverses the day with the month, I do not know how to deal with this situation , I tried to reverse again with the Tostring and assign to a DateTime
but error when the month is greater than 12.
This is my Controller :
[HttpPost]
[ValidateInput(false)]
public JsonResult Editar(string Titulo, string Descricao, DateTime DataCadastro, int ProdutoId)
{
int idProduto = Convert.ToInt32(ProdutoId);
var produto = ProdutoServico.GetById(idProduto);
if (Titulo != null && Descricao != null && DataCadastro != null )
{
produto.Descricao = Descricao;
produto.DataCadastro = DataCadastro;
produto.Titulo = Titulo;
ProdutoServico.Update(produto);
if (produto.CategoriaProdutoId == null)
{
return Json(new { redirectUrl = Url.Action("Index", "Produto", new {CategoriaId = 0, area = "Lojista" }), isRedirect = true });
}
else
{
return Json(new { redirectUrl = Url.Action("Index", "Produto", new { CategoriaId = produto.CategoriaProdutoId.Value, area = "Lojista" }), isRedirect = true });
}
}
return Json(new { redirectUrl = Url.Action("Index", "Produto", new { CategoriaId = produto.CategoriaProdutoId.Value, area = "Lojista" }), isRedirect = true });
}
in this controller the date arrives correct example : 30/09/2016
but after he saves he tries to save so: 09/30/2016
I don’t know how to fix this.
recalling that the server is in the US, thank you very much.
You want to record it as en en at the bank or display as en?
– Ricardo
Use
ToString
to format is a big problem, huh.– Jéf Bueno
the date has no format, the presentation is what it has. You must always generate the text you wish or make the application interpret in this way: http://answall.com/a/141232/101, http://answall.com/q/121440/101, http://answall.com/q/136014/101, http://answall.com/q/118450/101, http://answall.com/q/68247/101
– Maniero
So the problem is that at the time of saving I check the 'Datetime' and it’s right , example 'Mounth = 9 and' Day = 11' But when you save it from error.
– William Cézar
Globalization on the web config solved my problem , vlw
– William Cézar