ADITYA JADHAV
ADITYA JADHAV

Reputation: 9

How to calculate next months dates?

I want to calculate next months 5 date.

For e.g consider todays 10-jan-2017 date then next date should be between next months 5th. i.e before 05-feb-2017

Upvotes: 0

Views: 69

Answers (2)

Pranav C Balan
Pranav C Balan

Reputation: 115282

Use Date#setMonth method with both month and day arguments.

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

Upvotes: 0

Kim Hoang
Kim Hoang

Reputation: 1368

You can use momentjs to handle date. http://momentjs.com/docs/

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

Upvotes: 1

Related Questions