js implements date calculation

js implements date calculation

/**
 * AddDayCount needs to increase or decrease the number of days
 */

function changDate(AddDayCount){
var dd=new Date();
dd.setDate(dd.getDate()+AddDayCount);//Get the date after AddDayCount days 
var y = dd.getFullYear(); 
var m = dd.getMonth()+1;//Get the date of the current month 
if(parseInt(m)<10){
m="0"+m;
}
var d = dd.getDate();
if(parseInt(d)<10){
d="0"+d;
}
return y+"/"+m+"/"+d; //return the calculated date
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325516278&siteId=291194637