Increment Date in Javascript

Following is the function to increment date by one day in javascript.

   function IncrementDate(date) {         
         var tempDate = new Date(date);
            tempDate.setDate(tempDate.getDate() + 1);
            return tempDate;

Function calling...

 var currentDate = new Date();
 var IncrementedDate =  IncrementDate(currentDate);

Here we use the setDate method of Date variable to increment date.

For exploring more in programming on this blog click here


Post a Comment