How can I add 1 day to current date?

后端 未结 6 1831
温柔的废话
温柔的废话 2020-11-22 01:13

I have a current Date object that needs to be incremented by one day using the JavaScript Date object. I have the following code in place:

var ds = stringFor         


        
6条回答
  •  终归单人心
    2020-11-22 02:08

    int days = 1;
    var newDate = new Date(Date.now() + days*24*60*60*1000);
    

    CodePen

    var days = 2;
    var newDate = new Date(Date.now()+days*24*60*60*1000);
    
    document.write('Today: ');
    document.write(new Date());
    document.write('
    New: '); document.write(newDate);

提交回复
热议问题