4

I have a Action Method like this

public ActionResult TodayJson()
        {
            DateTime today = DateTime.Today;
            return Json(today,JsonRequestBehavior.AllowGet);
        }

that returns me the the following value

"\/Date(1369332000000)\/"

How can I parse it in actual date time by the jquery or java script. Format should be like this dd-mm-yyyy

Atish Kumar Dipongkor
  • 10,220
  • 9
  • 49
  • 77

1 Answers1

6

Use this in your javascript (while jsonDate = "\/Date(1369332000000)\/"):

var date = new Date(parseInt(jsonDate.substr(6)));
var formattedDate = date.format("dd-MM-yyyy");

Source: How do I format a Microsoft JSON date?

Community
  • 1
  • 1
Adam Tal
  • 5,911
  • 4
  • 29
  • 49