Javascript Date Plus 2 Weeks (14 days)

后端 未结 8 1761
孤街浪徒
孤街浪徒 2020-12-05 17:00

I use this to get the date:

var currentTime = new Date()
var month = currentTime.getMonth() + 1
var day = currentTime.getDate()
var year = currentTime.getFu         


        
8条回答
  •  萌比男神i
    2020-12-05 17:57

    add the following prototype method

    Date.prototype.addDays = function(days) {
         this.setDate(this.getDate()+days);
    }
    

    and than its very simple to use,

    currentTime.addDays(5);
    

提交回复
热议问题