将序列化的C#DateTime转换为JS Date对象

时间:2011-08-03 14:41:14

标签: c# javascript json serialization

如何将日期格式/Date(1302589032000+0400)/转换为JS Date对象?

1 个答案:

答案 0 :(得分:18)

首先删除文字:

var src = "/Date(1302589032000+0400)/";

//Remove all non-numeric (except the plus)
src = src.replace(/[^0-9 +]/g, ''); 

//Create date
var myDate = new Date(parseInt(src));

Here's a workding jsFiddle