Javascript 向java脚本中选择的随机日期添加一年

Javascript 向java脚本中选择的随机日期添加一年,javascript,asp.net-mvc-4,date,datepicker,Javascript,Asp.net Mvc 4,Date,Datepicker,我有两个字段开始日期和结束日期。我正在尝试将一年添加到为开始日期选择的日期。这是我的看法 @Html.TextBoxFor(m => m.StartDate, new {id="StartDateId", style="width: 113px;", onblur = "dateformat(this,'MM/DD/YYYY')"}) <img src="~/Images/calendar.jpg" onclick="scwShow(StartDateId

我有两个字段开始日期和结束日期。我正在尝试将一年添加到为开始日期选择的日期。这是我的看法

    @Html.TextBoxFor(m => m.StartDate, new {id="StartDateId", style="width: 113px;", onblur = "dateformat(this,'MM/DD/YYYY')"})  
       <img src="~/Images/calendar.jpg"  onclick="scwShow(StartDateId,event,'MM/DD/YYYY');return false;" width="17" height="16"/>


@Html.TextBoxFor(m => m.EndDate, new {id="EndDateId", style="width: 113px;", onblur = "dateformat(this,'MM-DD-YYYY')" }) 
      <img src="~/Images/calendar.jpg"  onclick="scwShow(EndDateId,event,'MM-DD-YYYY');return false;" width="17" height="16"/> 

请帮助我如何设置所选时间的格式。如果学校提供了setFullYear函数,如何进一步进行月、年的加减操作。 你可以直接加上或减去任何你想要的日期

见示例:

<html>
<body>

<p>Click the button to display the date 1 year ahead of the given date.</p>

<button onclick="myFunction()">Try it</button>

<p id="demo"></p>

<script>
function myFunction() {
    var d = new Date();
    d.setFullYear(d.getFullYear(), d.getMonth() +12);
    document.getElementById("demo").innerHTML = d;
}
</script>

</body>
</html>
[

futureDate=myDate.setFullYearmydate.getFullYear+1?
<html>
<body>

<p>Click the button to display the date 1 year ahead of the given date.</p>

<button onclick="myFunction()">Try it</button>

<p id="demo"></p>

<script>
function myFunction() {
    var d = new Date();
    d.setFullYear(d.getFullYear(), d.getMonth() +12);
    document.getElementById("demo").innerHTML = d;
}
</script>

</body>
</html>