Question:
How do I send to View()
of my Controller in Json format, the date formatted in pattern dd-MM-yyyy hh:mm:ss
?
When transporting data between View and Controller, I'm using AJAX.
public ActionResult GetList(Object abc) {
...
ObjEntity temp = methodGetInDB();
string valueJson = new JavaScriptSerializer().Serialize(temp);
//Saída temp: "Date":"\/Date(1483290061000)\/"
}
Answer:
One way out would be to convert the DateTime to formatted string and then return it to view as json.
Ex: DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss");