My ASP MVC controller returns the results of the database in Json and the date field in epoch:
public ActionResult List(int id)
{
IEnumerable<object> query = (from a1 in db.Persons
where a1.personID == id
select new
{
personID = a1.personID,
date = a1.Date,
Firstname = a1.Firstname,
Lastname = a1.Lastname,
}).ToList();
return Json(query);
}
The Jquery result:
{firstName:'James',lastName:'Smith',date:"/Date(1447110000000)/"},
{firstName:'Susan',lastName:'Smith',date:"/Date(1447110000000)/"},
....
See more at: http://jsfiddle.net/EZUEF/749/
I tried to do it in the controller with:
date = a1.Date..ToString("dd/MM/yyyy")
It does not work. What is the best solutions to convert the Epoch date to dd/mm/yyyy? In KnockoutJS or in the controller?