JS日期数据加天数转化

Date.prototype.toCommonCase=function(){
			var xYear=this.getYear();
			xYear=xYear+1900;
			
			var xMonth=this.getMonth()+1;
			if(xMonth<10){
				xMonth="0"+xMonth;
			}
			var xDay=this.getDate();
			if(xDay<10){
				xDay="0"+xDay;
			}
			return xYear+"-"+xMonth+"-"+xDay;
		} //转化日期到标准格式

if (item.publish_time != null) {
		var dur = item.duration;
		var d = new Date(item.publish_time);
		var endDate=new Date(item.publish_time);
		endDate.setDate(d.getDate() + dur);
		out += "截止日期" + endDate.toCommonCase() + "";
	}

你可能感兴趣的:(JS日期数据加天数转化)