首页 > 语言 > JavaScript > 正文

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

2024-05-06 14:14:26
字体:
来源:转载
供稿:网友
代码如下:
//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);
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表

图片精选