2

How to add days to date with ISO 8601 Format using Javascript.

var date = new Date(2013, 9, 18, 18, 0, 0);
var myDate = date + 1
Mzoughi Yahya
  • 69
  • 3
  • 9
  • 1
    There is no ISO-8601 anywhere in that question. :-) ISO-8601 is a way to describe dates as *text*, e.g. `"2013-10-18T18:00:00"`. JavaScript doesn't do ISO-8601 (although it [does something very similar](http://blog.niftysnippets.org/2014/07/javascripts-datetime-format-is-not-iso.html)). – T.J. Crowder Sep 08 '14 at 16:29

2 Answers2

7

This will add a day to the date:

date.setDate(date.getDate()+1);
Barmar
  • 741,623
  • 53
  • 500
  • 612
  • 1
    @IshanMahajan Works for me. I just set the variable to today's date (July 31), and when I used `setDate(date.getDate()+1)` it changed to August 1. – Barmar Jul 31 '17 at 06:16
  • @IshanMahajan If you can't get it to work, post a question showing your code. – Barmar Jul 31 '17 at 06:18
2

Take a look at the api for Date over on MDN.

var date = new Date(2013, 9, 18, 18, 0, 0);
date.setDate(date.getDate() + 1);
damian
  • 1,419
  • 1
  • 22
  • 41