Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Adding days to any  date in javascript

Posted on 2014-02-04
Medium Priority
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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 2000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
This article discusses how to implement server side field validation and display customized error messages to the client.
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

722 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