Home  >  Article  >  Web Front-end  >  javascript current date plus (day, week, month, year)_time and date

javascript current date plus (day, week, month, year)_time and date

WBOY
WBOYOriginal
2016-05-16 18:48:241350browse
复制代码 代码如下:

//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);
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn