views:

36

answers:

3

I am trying to manipulate a javascript date object, to increment it by one day:

var now = new Date(+1 day);

What are the javascript options for something like this...

EDIT: cheers

+3  A: 

Like this:

var now = new Date();
now.setDate(now.getDate() + 1);

setDate will correctly convert January 32 into February 1.

SLaks
for some reason I had the impression this wasn't doing what it should be. Of course it was, and my error was elsewhere. cheers
kalpaitch
+1  A: 

Like this:

var myDate=new Date();
myDate.setDate(myDate.getDate()+1);

setDate will increase the current date with 1, hope this will help.

Tim
+1  A: 

Some straightforward answers have been posted, but just do you know, W3Schools has a fantastic Javascript date object reference page.

Cyrena
W3Schools isn't great. https://developer.mozilla.org/en/JavaScript/Reference/global_objects/date
SLaks
…and is totally unrelated to **W3C**. Moreover, you should have posted this as a comment, not as an answer to this question.
Marcel Korpel