Json 的日期格式如:"/Date(1243453335497+0800)/" ,为了正确输出如下格式“ 2011年5月15日 15:39:00”,需要进行转换,
提供脚本函数如下:
function dateFromStringWithTime(str) {
var match;
if (!(match = str.match(/\d+/))) {
return false;
}
var date = new Date();
date.setTime(match[0] - 0);
return date.toLocaleString();
}
var objDate = dateFromStringWithTime(result.Items[msg].PostTime);
objDate即为所要的时间格式。
如: 2011年5月15日 12:12:00
阅读全文类别:程序人生 查看评论