首頁  >  文章  >  web前端  >  javascript 当前日期加(天、周、月、年)_时间日期

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

WBOY
WBOY原創
2016-05-16 18:48:241349瀏覽
复制代码 代码如下:

//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);
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn