This question already has an answer here:
这个问题在这里已有答案:
- ASP.NET MVC JsonResult Date Format 22 answers
ASP.NET MVC JsonResult日期格式22个答案
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
如何通过jquery或java脚本在实际日期时间内解析它。格式应该像这个dd-mm-yyyy
1 个解决方案
#1
6
Use this in your javascript (while jsonDate = "\/Date(1369332000000)\/"
):
在你的javascript中使用它(当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?
来源:如何格式化Microsoft JSON日期?
#1
6
Use this in your javascript (while jsonDate = "\/Date(1369332000000)\/"
):
在你的javascript中使用它(当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?
来源:如何格式化Microsoft JSON日期?