javascript转换.net DateTime方法 (比如转换\/Date(1426056463000)\/)

function getDate(str_time) {
var re = new RegExp('\\/Date\\(([-+])?(\\d+)(?:[+-]\\d{4})?\\)\\/');
var r = (str_time || '').match(re);
var format = r ? new Date(((r[1] || '') + r[2]) * 1) : null;
return r ? new Date(((r[1] || '') + r[2]) * 1) : null;
}
function formatDate(now) {
var year = now.getYear()+1900;
var month = now.getMonth() + 1;
var date = now.getDate();
var hour = now.getHours();
var minute = now.getMinutes();
var second = now.getSeconds();
return year + "-" + month + "-" + date + " " + hour + ":" + minute + ":" + second;
}

var d=formatDate(getDate('/Date(1426056463000)/'));

posted on 2015-03-11 18:42  李九妹  阅读(988)  评论(0编辑  收藏  举报