您的位置:首页 > Web前端 > JavaScript

被Json格式化后那可怜的时间

2015-11-20 17:10 615 查看
function renderTime(date) {
var da = new Date(parseInt(date.replace("/Date(", "").replace(")/", "").split("+")[0]));
Year = da.getFullYear(); //ie火狐下都可以
Month = da.getMonth() + 1;
Day = da.getDate();

var CurrentDate = "";
CurrentDate += Year + "-";
if (Month >= 10) {
CurrentDate += Month + "-";
}
else {
CurrentDate += "0" + Month + "-";
}
if (Day >= 10) {
CurrentDate += Day;
}
else {
CurrentDate += "0" + Day;
}
return CurrentDate + " " + da.getHours() + ":" + da.getSeconds() + ":" + da.getMinutes();
}


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: