2

In Dojo javascript, after entering from date in a datetextbox , how do I add 4 months to that selected date and display it in a text box?
Any help on this will be valuable.

Kevin
  • 53,822
  • 15
  • 101
  • 132
Shirish
  • 21
  • 2

1 Answers1

3

You can do this with the dojo.date tools:

var enteredDate  = myDateTextBox.get("value"),
    modifiedDate = dojo.date.add(enteredDate, "month", 4);

myTextBox.set("value", modifiedDate.toUTCString());

This assumes you have dojo.require("dojo.date");. Take a look at http://dojotoolkit.org/api/1.7/dojo/date for an overview of Dojo's date functions.

It's not technically necessary to use Dojo for this at all, though. See this question: Javascript function to add X months to a date .

Community
  • 1
  • 1
Frode
  • 5,600
  • 1
  • 25
  • 25