JavaScript–Adding months or days to a date

Goal:

Add moths or days (or other increments) to a date in JavaScript.

Solution:

var current = new Date();

var threeMonthsInTheFuture =  new Date(new Date(current).setMonth(current.getMonth() + 3));

for days use:

getDate()

for hours use:

getHours().

 

and so on….

Print | posted @ Friday, November 18, 2016 9:50 AM

Comments on this entry:

No comments posted yet.

Post A Comment
Title:
Name:
Email:
Comment:
Verification: