// 重载时间日期的toLocaleString方法(根据具体需求定义)
Date.prototype.toLocaleString = function() {
return this.getFullYear() + "-" + (((this.getMonth() + 1)) < 10 ? '0' + (this.getMonth() + 1) : (this.getMonth() + 1)) + "-"
+ ((this.getDate() < 10) ? '0' + this.getDate() : this.getDate()) + " "
+ ((this.getHours() < 10) ? '0' + this.getHours() : this.getHours()) + ":"
+ ((this.getMinutes() < 10) ? '0' + this.getMinutes() : this.getMinutes()) + ":"
+ ((this.getSeconds() < 10) ? '0' + this.getSeconds() : this.getSeconds());
};
/**
* 计算新的时间
* @param day 多少天(负数表示以前时间,正数表示以后的时间)
* @param hour 多少小时(负数表示以前时间,正数表示以后的时间)
* @returns {string} 格式化的时间格式,如:2017-05-28 05:56:30
*/
function getNewTime(day, hour) {
var mscornd = new Date().getTime();
var resDate = mscornd + (24 * 3600 * 1000 * day) + (3600 * 1000 * hour);
return new Date(resDate).toLocaleString();
}