首页 > 编程 > JavaScript > 正文

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

2019-11-21 01:12:37
字体:
来源:转载
供稿:网友
复制代码 代码如下:

//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);
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表