Convert serialized C# DateTime to JS Date object

北城以北 提交于 2019-12-22 03:57:05

问题


How can I convert that date format /Date(1302589032000+0400)/ to JS Date object?


回答1:


Remove the text first:

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



来源:https://stackoverflow.com/questions/6928281/convert-serialized-c-sharp-datetime-to-js-date-object

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!