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

上一篇:LINQ to SQL语句(14)之Null语义和DateTime


下一篇:Python时间与日期操作(datetime、time、calendar)