Get next date from given date in javascript

date
javascript
next date

We need to add one day for the given date.  The given date is '24-03-2017'.  By using the below javascript code get next date.

var date = '24-03-2017';
var nextday = new Date(date.setTime( date.getTime() + 1 * 86400000 ));
var day = nextday.getDate();
var months = (nextday.getMonth() + 1);
// Months use 0 index.		
var nextdate= nextday.getFullYear()+'-'+(months[1] ? month :  '0'+ months[0]) + '-' +  (day[1] ? day :  '0'+ day[0]);	

 

The result is : 

25-03-2017

You might also like:

Functions in javascript

25-05-2018 functions javascript es5 es6 arrow functions named functions Closures Nested Functions Callbacks Arrow functions.

Sanitization in java sript

14-03-2017 sanitization java script

Convert Time 24 hrs to 12 hrs format In javascript

12-03-2017 date javascript 12hrs convert

Using slice remove last two characters from given string

07-03-2017 slice remove

Send Mail in Node Js

21-02-2017 node js mail npm module