1

How to add days to javascript unix timestamp?

We can get the current time in timestamp using the following method:

Date.now()

Following is the method for adding days to a date.

Date.prototype.addDays = function(days) {
    var date = new Date(this.valueOf());
    date.setDate(date.getDate() + days);
    return date;
}

var date = new Date();

console.log(date.addDays(5));

But this method does not return a unix timestamp.

How can I add days to a unix timestamp?

mx_code
  • 2,441
  • 1
  • 12
  • 37

0 Answers0