Home  >  Article  >  Web Front-end  >  转换json格式的日期为Javascript对象的函数_javascript技巧

转换json格式的日期为Javascript对象的函数_javascript技巧

WBOY
WBOYOriginal
2016-05-16 18:23:26936browse
复制代码 代码如下:

//转换json格式的日期(如:{ServerDatetime:"\/Date(1278930470649)\/"})为Javascript的日期对象
function ConvertJSONDateToJSDateObject(JSONDateString) {
var date = new Date(parseInt(JSONDateString.replace("/Date(", "").replace(")/", ""), 10));
return date;
}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn