Get tomorrow and yesterday - Node.js Date

Node.js examples for Date:Day

Description

Get tomorrow and yesterday

Demo Code

Date.prototype.tomorrow = function() {
  return new Date(
    this.getFullYear(),//from   w ww .  j av a2 s .c o m
    this.getMonth(),
    this.getDate() + 1,
    this.getHours(),
    this.getMinutes(),
    this.getSeconds(),
    this.getMilliseconds()
  );
};

Date.prototype.yesterday = function() {
  return new Date(
    this.getFullYear(),
    this.getMonth(),
    this.getDate() - 1,
    this.getHours(),
    this.getMinutes(),
    this.getSeconds(),
    this.getMilliseconds()
  );
};

Related Tutorials