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

 更新时间:2009年08月09日 01:16:11   作者:  
javascript当前日期加(天、周、月、年) ,有需要操作日期的朋友,可以参考下。
复制代码 代码如下:

//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);

相关文章

最新评论