关于js中对当前日期加n天的实现

function AddDays(dayIn) {
	var date=new Date();
	var myDate=new Date(date.getTime()+dayIn*24*60*60*1000);
	var year=myDate.getFullYear();
	var month=myDate.getMonth()+1;
	var day=myDate.getDate();
	CurrentDate=year+"-";
	if(month>=10)
	{
		CurrentDate=CurrentDate+month+"-";
	}
	else
	{
		CurrentDate=CurrentDate+"0"+month+"-";
	}
	if(day>=10)
	{
		CurrentDate=CurrentDate+day;
	}
	else
	{
		CurrentDate=CurrentDate+"0"+day;
	}
	return CurrentDate;
}


比如当前时间是2000-01-01 加六天就是2000-01-07

你可能感兴趣的:(关于js中对当前日期加n天的实现)