Adding days to any  date in javascript

Posted on 2014-02-04
Last Modified: 2014-03-09
How to add 31 days to the date in JavaScript?
Both dates must be in format MM/DD/YY.
Question by:niceguy971
LVL 33

Expert Comment

by:Big Monty
ID: 39833680
try this:

var today = new Date();
var newDay = new Date();

Open in new window


Author Comment

ID: 39833696
Hi Big Monty, it does  Not answer my question!!! The format must be MM/DD/YY
LVL 33

Accepted Solution

Big Monty earned 500 total points
ID: 39833717
var today = new Date();
var newDay = new Date();

finalMonth = newDay.getMonth() + 1;
finalDay = newDay.getDate();
finalYear = newDay.getYear();

var result = finalMonth + '/' + finalDay + '/' + finalYear;

Open in new window

LVL 19

Expert Comment

by:Ken Butters
ID: 39833811
I think this would be simpler for the formatting part....

var newDay = new Date();

var result =newDay.format("mm/dd/yy");

Expert Comment

ID: 39835158
The getDate method will return a day between 1 and 31 (see

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Any Way to rotate banner ads from Commission Junction? 2 38
Hide and Unhide Table 6 27
Ajax on ASP 2 43
sort Multi-dimensional array 6 19
When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question