站长资源网络编程

javascript 当前日期加(天、周、月、年)

整理:jimmy2026/8/6浏览2
简介复制代码 代码如下://create the date var myDate = new Date(); //add a day to the date myDate.setDate(myDate.getDate() + 1); //add a week myDate.setDate(myDate.
复制代码 代码如下:
//create the date
var myDate = new Date();

//add a day to the date
myDate.setDate(myDate.getDate() + 1);

//add a week
myDate.setDate(myDate.getDate() + 7);

//add a month
myDate.setMonth(myDate.getMonth() + 1);

//add a year
myDate.setYear(myDate.getYear() + 1);