2017-01-10 114 views

回答

0

使用Date#setMonth方法與月和日參數。

// get current date 
 
var date = new Date(); 
 

 
// add month and update day 
 
date.setMonth(date.getMonth() + 1, 5); 
 
// or set day by date.setDate(5); 
 

 
console.log(date);

+0

(date.getMonth()+ 1)%12 –

+0

and year = date.getYear()+(date.getMonth()+ 1)/ 12 –

+0

@UG_會導致'05-dec-如果您指定的參數超出了預期的範圍,setMonth()將嘗試更新「05-jan-2018」或「05-jan-2018」# –

1

您可以使用momentjs處理日期。 http://momentjs.com/docs/

var today = moment(); 
var nextDate = today.add(1, 'months').startOf('month').add(5, 'days');