2

I want to add one day to my date how can I do that my date is date = new Date();

date = new Date();
endDate = this.date.toString();
Harry Ninh
  • 15,280
  • 5
  • 59
  • 54
Debashish Dwivedi
  • 197
  • 2
  • 3
  • 12
  • Possible duplicate of [Incrementing a date in JavaScript](https://stackoverflow.com/questions/3674539/incrementing-a-date-in-javascript) – Roman Aug 24 '17 at 05:55

7 Answers7

3
date = new Date();
date.setDate(date.getDate() + 1);
endDate = this.date.toString(); 

For more details

1

I think it is much nicer to use momentjs like:

 moment(new Date().toString(), "DD-MM-YYYY").add(1, 'days')

or even shorthand

moment().add(1, 'd');

checkout more on .add() operator here

angularrocks.com
  • 21,413
  • 12
  • 82
  • 101
1

Another way to do it with moment:

moment().add(1, 'day');
Junbang Huang
  • 1,819
  • 17
  • 24
1

Use This way

var date = new Date();
date.setDate(date.getDate()+1);
angularrocks.com
  • 21,413
  • 12
  • 82
  • 101
M K
  • 1,361
  • 2
  • 8
  • 20
0

Or pure javascript, using milliseconds:

var date = new Date();
date.setTime(date*1+86400000);
F. Hauri
  • 58,205
  • 15
  • 105
  • 122
0

Try :

date = new Date();
endDate = date;
endDate.setDate(date.getDate() + 1);

alert(endDate);
Yogesh Borkhade
  • 606
  • 5
  • 10
0
var now = new Date(); // Fri Feb 20 2015 19:29:31 GMT+0530 (India Standard Time) 
var isoDate = new Date(now.getTime() - now.getTimezoneOffset() * 60000).toISOString();
//OUTPUT : 2015-02-20T19:29:31.238

Try This!

HariKishore
  • 129
  • 7