Javascript Date tomorrow()

Description

Javascript Date tomorrow()


Date.prototype.tomorrow = function() {
  var todayNum = this.getDay();
  var days = {//from  ww  w  . ja va 2s . c o  m
    0: "Sunday",
    1: "Monday",
    2: "Tuesday",
    3: "Wednesday",
    4: "Thursday",
    5: "Friday",
    6: "Saturday"
  }
  return "Tomorrow is " + days[todayNum+1];
}

console.log("What day is tomorrow?");
console.log((new Date()).tomorrow());

Javascript Date tomorrow()

Date.prototype.tomorrow = function() {
  var tomorrow = new Date(this);
  tomorrow.setDate(this.getDate()+1);//  w  ww .  j a v a  2s. co  m
  return tomorrow;
}



PreviousNext

Related