js获取当前时间的前一天/后一天 ,前一月/后一月

js获取当前时间的前一天/后一天

Date curDate = new Date();
var preDate = new Date(curDate.getTime() - 24*60*60*1000); //前一天
var nextDate = new Date(curDate.getTime() + 24*60*60*1000); //后一天



前一月/后一月

var now = new Date();
now.setMonth(now.getMonth()-1);
var now2 = new Date();
now2.setMonth(now.getMonth()+1);
alert(now2);

猜你喜欢

转载自blog.csdn.net/ch834301/article/details/80712112