Javascript Date getNextDay()

Description

Javascript Date getNextDay()


//extend date instance to return next day
Date.prototype.getNextDay =function() {
   day = this.getDay()+1;  //add 1 to day to get next day
  return (day);//from  w  ww  .j a va2 s .com
};
//create date object of particular date
var mydate = new Date('2016-01-09');
document.write(mydate.toDateString()+"<br>");
document.write(mydate.getNextDay());

//create date object

//create date object

var d = new Date();
document.write(d.getNextDay());

Javascript Date getNextDay()

/**/*from   ww  w .  jav  a 2 s  .  c o  m*/
* FileName:dateExtension.js
* CreatedBy: Vamsee
* Date :27-08-2016
* Purpose : Function to extend date object and to return nextDay
*/
/**
* Adding getNextDay function to Date prototype
* The function will return nextDate
*/
Date.prototype.getNextDay = function() {
    var today = this.getDay(); 
    var next = today + 1;
    nextDate = next+":"+this.getMonth()+":"+this.getFullYear();
    //return new Date(this.setDate(today + 1));
    return nextDate;
}
/*creating the Date instance*/
var d = new Date();
/*calling the nextDay method on date instance */
console.log(d.getNextDay());



PreviousNext

Related