How to serialize a dateTime displaying in dd-MM-yyyy format hh: mm: ss

2

How do I send to View() of my Controller in Json format, the date formatted in the dd-MM-yyyy hh:mm:ss pattern?

In the data transport 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)\/"

}
    
asked by anonymous 06.01.2017 / 20:23

1 answer

1

An output 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");

    
06.01.2017 / 20:32