0

i have table with these fields sms,id,updtd_date. im trying get it in json but date value getting in different format. how to get updt_time field in string in json

o/p

/Date(1497309538000)/

req op

13-06-2017 04:48

code

 public ActionResult getSMS()
        {
            using (DBEntities dc = new DBEntities())
            {
                var data = dc.sms.OrderByDescending(a => a.id).ToList();
                return Json(new { data = data }, JsonRequestBehavior.AllowGet);
            }
        }
dotnetcoder
  • 51
  • 1
  • 1
  • 11

1 Answers1

0

You can serialize your date manually:

public ActionResult getSMS()
{
    using (DBEntities dc = new DBEntities())
    {
        var data = dc.sms.OrderByDescending(a => a.id);
        return Json(data.Select(d => new { d.sms, d.id, updtd_date = d.ToString("dd-MM-yyyy HH:mm") }).ToList(), JsonRequestBehavior.AllowGet);

    }
}
Aleks Andreev
  • 7,016
  • 8
  • 29
  • 37