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)/'));

原文地址:https://www.cnblogs.com/xy99/p/4330711.html