How to add days to the now date in javascript?

datetime, javascript

Solution

Try one of the two way will work for you...

function addDays(myDate,days) {
return new Date(myDate.getTime() + days*24*60*60*1000);
}

DEMO1

or

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

DEMO2

Problem

``` var myDate = new Date(); var endtime= new Date(myDate.getDate()+1,23:59:59); alert(endtime); ``` why there is no value of the endtime? if i want to add 1 day 10 hours 50 minute 30 second to the now time, how to wirte the endtime code? thank you

Original source

Related problems